Skip to content

Commit

Permalink
feat: add / update comments in refresh function
Browse files Browse the repository at this point in the history
  • Loading branch information
dleard committed Mar 29, 2021
1 parent 3ab3100 commit 85dc622
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 5 deletions.
23 changes: 23 additions & 0 deletions app/server/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26480,6 +26480,11 @@ type FormJson implements Node {
"""The person who updated the form"""
createdBy: Int

"""
The default_form_result column defines the shape of an empty form_result created from this form_json row
"""
defaultFormResult: JSON

"""The date the form was deleted"""
deletedAt: Datetime

Expand Down Expand Up @@ -27106,6 +27111,9 @@ input FormJsonCondition {
"""Checks for equality with the object’s `createdBy` field."""
createdBy: Int

"""Checks for equality with the object’s `defaultFormResult` field."""
defaultFormResult: JSON

"""Checks for equality with the object’s `deletedAt` field."""
deletedAt: Datetime

Expand Down Expand Up @@ -27159,6 +27167,9 @@ input FormJsonFilter {
"""Filter by the object’s `createdBy` field."""
createdBy: IntFilter

"""Filter by the object’s `defaultFormResult` field."""
defaultFormResult: JSONFilter

"""Filter by the object’s `deletedAt` field."""
deletedAt: DatetimeFilter

Expand Down Expand Up @@ -27213,6 +27224,11 @@ input FormJsonInput {
"""The person who updated the form"""
createdBy: Int

"""
The default_form_result column defines the shape of an empty form_result created from this form_json row
"""
defaultFormResult: JSON

"""The date the form was deleted"""
deletedAt: Datetime

Expand Down Expand Up @@ -27264,6 +27280,11 @@ input FormJsonPatch {
"""The person who updated the form"""
createdBy: Int

"""
The default_form_result column defines the shape of an empty form_result created from this form_json row
"""
defaultFormResult: JSON

"""The date the form was deleted"""
deletedAt: Datetime

Expand Down Expand Up @@ -27337,6 +27358,8 @@ enum FormJsonsOrderBy {
CREATED_AT_DESC
CREATED_BY_ASC
CREATED_BY_DESC
DEFAULT_FORM_RESULT_ASC
DEFAULT_FORM_RESULT_DESC
DELETED_AT_ASC
DELETED_AT_DESC
DELETED_BY_ASC
Expand Down
64 changes: 64 additions & 0 deletions app/server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38677,6 +38677,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "defaultFormResult",
"description": "The default_form_result column defines the shape of an empty form_result created from this form_json row",
"args": [],
"type": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "deletedAt",
"description": "The date the form was deleted",
Expand Down Expand Up @@ -83124,6 +83136,16 @@
},
"defaultValue": null
},
{
"name": "defaultFormResult",
"description": "Checks for equality with the object’s `defaultFormResult` field.",
"type": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
},
"defaultValue": null
},
{
"name": "deletedAt",
"description": "Checks for equality with the object’s `deletedAt` field.",
Expand Down Expand Up @@ -83303,6 +83325,16 @@
},
"defaultValue": null
},
{
"name": "defaultFormResult",
"description": "Filter by the object’s `defaultFormResult` field.",
"type": {
"kind": "INPUT_OBJECT",
"name": "JSONFilter",
"ofType": null
},
"defaultValue": null
},
{
"name": "deletedAt",
"description": "Filter by the object’s `deletedAt` field.",
Expand Down Expand Up @@ -83498,6 +83530,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "DEFAULT_FORM_RESULT_ASC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "DEFAULT_FORM_RESULT_DESC",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "DELETED_AT_ASC",
"description": null,
Expand Down Expand Up @@ -121341,6 +121385,16 @@
},
"defaultValue": null
},
{
"name": "defaultFormResult",
"description": "The default_form_result column defines the shape of an empty form_result created from this form_json row",
"type": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
},
"defaultValue": null
},
{
"name": "deletedAt",
"description": "The date the form was deleted",
Expand Down Expand Up @@ -133218,6 +133272,16 @@
},
"defaultValue": null
},
{
"name": "defaultFormResult",
"description": "The default_form_result column defines the shape of an empty form_result created from this form_json row",
"type": {
"kind": "SCALAR",
"name": "JSON",
"ofType": null
},
"defaultValue": null
},
{
"name": "deletedAt",
"description": "The date the form was deleted",
Expand Down
11 changes: 6 additions & 5 deletions schema/deploy/swrs_functions/refresh_swrs_version_data.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- Deploy ggircs-portal:swrs_functions/refresh_swrs_version_data to pg
-- requires: tables/form_json_001
-- requires: tables/form_result
-- requires: swrs_functions/init_application_administration_form_result
-- requires: swrs_functions/init_application_emission_form_result
Expand All @@ -16,8 +17,8 @@ declare
new_form_result jsonb;
query text;
empty_form_result jsonb;
temp_row record;
begin

for application_temp_row in select * from ggircs_portal.application
loop
report_imported_at := (select imported_at from swrs.report r where r.id = application_temp_row.report_id);
Expand Down Expand Up @@ -55,11 +56,11 @@ begin

for form_json_temp_row in select form_id from ggircs_portal.ciip_application_wizard where is_active=true
loop

if ((select updated_at from ggircs_portal.form_result fr
-- Compare timestamp (truncated to day) of form_result.updated_at to timestamp (truncated to day) of report.imported_at
if ((select date_trunc('day', updated_at) from ggircs_portal.form_result fr
where fr.form_id = form_json_temp_row.form_id
and fr.application_id = application_temp_row.id
and fr.version_number = 0) < report_imported_at)
and fr.version_number = 0) < date_trunc('day', report_imported_at))
then

select form_result_init_function from ggircs_portal.form_json fj where fj.id = form_json_temp_row.form_id into init_function;
Expand All @@ -84,6 +85,6 @@ end;

$function$ language plpgsql volatile;

comment on function ggircs_portal_private.refresh_swrs_version_data is 'This function updates the form results relating to the swrs version of an application (version 0) if the form results were updated prior to the import date of the report';
comment on function ggircs_portal_private.refresh_swrs_version_data is 'This function updates the form results relating to the swrs version of an application (version 0) if the form results were updated prior to the import date of the report. Creates the form results for version 0 if it does not exist';

commit;

0 comments on commit 85dc622

Please sign in to comment.