-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework database triggers to use FlowRun.delete_from_counts
#3702
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3702 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 488 489 +1
Lines 26167 26168 +1
=========================================
+ Hits 26167 26168 +1
Continue to review full report at Codecov.
|
responded=bool([e for e in run["events"] if e["type"] == "msg_received"]), | ||
) | ||
else: | ||
FlowRun.objects.filter(id=run_obj.id).update(**db_state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updating this to match more closely how things work in mailroom
---------------------------------------------------------------------- | ||
-- Increments or decrements our start counts for each exit type | ||
---------------------------------------------------------------------- | ||
CREATE OR REPLACE FUNCTION temba_update_flowstartcount() RETURNS TRIGGER AS $$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the INSERT part into temba_flowrun_insert
. We don't UPDATE start_id on flow runs except to trim starts.. at which point is more efficient to just delete the counts. We also don't need to update counts if runs are being deleted, and that might help make archiver deletes a little more efficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this matches what we talked about. I'm maybe a little spooked in that we are losing the ability to at least prove why counts don't add up (which we could still do in the archived case before), but I still feel this is the right direction.
So from now on, only result category counts will be decremented when a run row is deleted. Path, exit type and start counts remain unchanged. Less trying to rewind history.