-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2096 from bcgov/1212-increase-buffer
fix: add greater buffer time to prevent modal popup on intake form
- Loading branch information
Showing
5 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-- Deploy ccbc:mutations/update_application_form to pg | ||
|
||
begin; | ||
-- Since we're updating the function definition, need to manually drop | ||
drop function ccbc_public.update_application_form; | ||
|
||
create or replace function ccbc_public.update_application_form(form_data_row_id int, json_data jsonb, last_edited_page varchar, client_updated_at timestamp with time zone) | ||
returns ccbc_public.form_data as | ||
$func$ | ||
declare | ||
current_updated_at timestamp with time zone; | ||
updated_form_data ccbc_public.form_data; | ||
begin | ||
|
||
select updated_at into current_updated_at from ccbc_public.form_data where id = form_data_row_id; | ||
-- Adding a buffer, can be used to update if someone happens to have a version of the form that was opened <1 second from the last save | ||
-- Risk is that there can still be overwritten data. | ||
if client_updated_at < current_updated_at - interval '1 second' then | ||
raise exception 'Data is Out of Sync'; | ||
end if; | ||
|
||
update ccbc_public.form_data | ||
set | ||
-- use json concatenation operator to merge the provided json_data with the dynamic submission values | ||
json_data = $2 || jsonb_build_object( | ||
'submission', coalesce($2->'submission', jsonb_build_object()) || jsonb_build_object( | ||
'submissionCompletedFor', $2->'organizationProfile'->'organizationName', | ||
'submissionDate', (date_trunc('day', now(), 'America/Vancouver')::date) | ||
) | ||
), | ||
last_edited_page = $3 | ||
where id = form_data_row_id | ||
returning * into updated_form_data; | ||
|
||
return updated_form_data; | ||
end; | ||
$func$ language plpgsql; | ||
|
||
grant execute on function ccbc_public.update_application_form to ccbc_auth_user; | ||
|
||
comment on function ccbc_public.update_application_form is | ||
$$ | ||
Mutation to update the "application" form. | ||
This mutation should only be used by applicants as it sets the submission page data | ||
$$; | ||
|
||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Deploy ccbc:mutations/update_application_form to pg | ||
|
||
begin; | ||
|
||
drop function ccbc_public.update_application_form; | ||
|
||
create or replace function ccbc_public.update_application_form(form_data_row_id int, json_data jsonb, last_edited_page varchar) | ||
returns ccbc_public.form_data as | ||
$$ | ||
|
||
update ccbc_public.form_data | ||
set | ||
-- use json concatenation operator to merge the provided json_data with the dynamic submission values | ||
json_data = $2 || jsonb_build_object( | ||
'submission', coalesce($2->'submission', jsonb_build_object()) || jsonb_build_object( | ||
'submissionCompletedFor', $2->'organizationProfile'->'organizationName', | ||
'submissionDate', (date_trunc('day', now(), 'America/Vancouver')::date) | ||
) | ||
), | ||
last_edited_page = $3 | ||
where id = form_data_row_id | ||
returning *; | ||
|
||
$$ language sql; | ||
|
||
grant execute on function ccbc_public.update_application_form to ccbc_auth_user; | ||
|
||
comment on function ccbc_public.update_application_form is | ||
$$ | ||
Mutation to update the "application" form. | ||
This mutation should only be used by applicants as it sets the submission page data | ||
$$; | ||
|
||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters