Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added Hasura functions that accept an array of activity_ids and a plan_id and deletes all of the activities one at a time while handling their anchors with the specified resolution. Created so that the UI only needs to send a maximum of 4 requests when a user bulk deletes activity directives: one for each anchor resolution type and the default delete.
Having the
validate_anchors_update_trigger
runimmediately
during the function has it run per-statement instead of per-transaction, which avoids a foreign key violation that occurs if an activity is both updated and deleted during a function (ie, the input is{anchor, activity}
todelete_activity_by_pk_reanchor_plan_start_bulk
.activity
will be updated whenanchor
is processed and then deleted when it is processed.)Note regarding what these functions return: If an activity is both updated and deleted, or updated multiple times, there will be a row returned for each change.
Verification
Manually tested the functions and had no issues with running them or with the Hasura metadata.