Skip to content

Commit

Permalink
chore: spec work
Browse files Browse the repository at this point in the history
  • Loading branch information
BCerki committed Jul 24, 2023
1 parent 3a387db commit 1216149
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ begin
raise debug '%', query;
execute query using fc.form_data_record_id;
end if;

raise notice 'record_id in default handler %:',record_id;
return record_id;
end;
$$ language plpgsql volatile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ begin;
create or replace function cif_private.handle_project_summary_report_form_change_commit(fc cif.form_change)
returns int as $$
declare
reporting_requirement_record_id int;
reporting_requirement_record_id int;
begin
-- If there is no change in the form data, return the form_change record and do not touch the associated table.
if (fc.new_form_data = '{}') then
return fc.form_data_record_id;
end if;

if (fc.change_status = 'committed') then
raise exception 'Cannot commit form_change. It has already been committed.';
end if;
-- If there is no change in the form data, return the form_change record and do not touch the associated table.
if (fc.new_form_data = '{}') then
return fc.form_data_record_id; -- can be null if creating with empty form data...problem?
end if;

if (fc.change_status = 'committed') then
raise exception 'Cannot commit form_change. It has already been committed.';
end if;

if fc.operation = 'create' then
reporting_requirement_record_id := fc.form_data_record_id;

if fc.operation = 'create' then
insert into cif.reporting_requirement(
project_id,
report_type,
Expand Down Expand Up @@ -48,15 +51,10 @@ begin
(fc.new_form_data->>'dateSentToCsnr')::timestamptz
);

-- brianna is it this then? it sets it wrong? because it looks like it goes in right so it must be changed later. this is on create so that doesn't make sense
-- raise exception 'reporting_requirement_record_id: %', reporting_requirement_record_id;

update cif.form_change set form_data_record_id = reporting_requirement_record_id where id = fc.id;



elsif fc.operation = 'update' then
raise notice 'form_data_record_id in handle commit: %', to_json((select form_data_record_id from cif.form_change where id = fc.id order by id desc limit 1));
-- raise notice 'form_data_record_id in handle commit: %', to_json((select form_data_record_id from cif.form_change where id = fc.id order by id desc limit 1));

-- brianna missing payment notes?

Expand Down Expand Up @@ -86,7 +84,8 @@ begin
update cif.payment set archived_at = now() where reporting_requirement_id = fc.form_data_record_id;

end if;

-- brianna this reporting_requirement_record_id must be null sometimes
raise notice 'reporting_requirement_record_id in commit handler: %',reporting_requirement_record_id;
return reporting_requirement_record_id;
end;
$$ language plpgsql volatile;
Expand Down
3 changes: 2 additions & 1 deletion schema/deploy/mutations/commit_form_change_internal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ begin
'select "cif_private".%I($1)',
(select form_change_commit_handler from cif.form where slug = fc.json_schema_name)
) using fc into recordId;
-- brianna fc replaces $1. could it somehow be the wrong form change?

raise notice 'handler %',(select form_change_commit_handler from cif.form where slug = fc.json_schema_name);
raise notice 'THIS IS IT recordId: %', recordId;
raise notice 'fc is: %',fc;
-- raise notice 'fc is: %',fc;

update cif.form_change set
-- BRIANNA THIS IS IT! recordId is null for project summary report
Expand Down
12 changes: 6 additions & 6 deletions schema/deploy/mutations/create_project_revision.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ begin
project_revision_id => revision_row.id,
json_schema_name => form_change_record.json_schema_name
) ;
raise notice '!!!!!!!!!!!!!form_change_record.operation:%',form_change_record.operation;
raise notice '!!!!!!!!!!!!!form_change_record.form_data_table_name:%',form_change_record.form_data_table_name;
raise notice '!!!!!!!!!!!!!revision_row.id:%',revision_row.id;
raise notice '!!!!!!!!!!!!!form_change_record.json_schema_name:%',form_change_record.json_schema_name;
raise notice '!!!!!!!!!!!!!form_change_record.id:%',form_change_record.id;
-- raise notice '!!!!!!!!!!!!!form_change_record.operation:%',form_change_record.operation;
-- raise notice '!!!!!!!!!!!!!form_change_record.form_data_table_name:%',form_change_record.form_data_table_name;
-- raise notice '!!!!!!!!!!!!!revision_row.id:%',revision_row.id;

-- raise notice '!!!!!!!!!!!!!form_change_record.json_schema_name:%',form_change_record.json_schema_name;
-- raise notice '!!!!!!!!!!!!!form_change_record.id:%',form_change_record.id;
end loop;
return revision_row;
end;
Expand Down

0 comments on commit 1216149

Please sign in to comment.