Skip to content
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 msgs database triggers so we don't track counts for messages in archives #3691

Merged
merged 2 commits into from
Feb 21, 2022

Conversation

rowanseymour
Copy link
Member

@rowanseymour rowanseymour commented Feb 16, 2022

What if we didn't track all those counts we don't use

@@ -769,30 +752,6 @@ BEGIN
RAISE EXCEPTION 'Cannot change created_on on messages';
END IF;

-- Clean up counts when we are doing a real delete
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's never a scenario now where we distinguish between an archiver delete and a "real" delete. the msg existed so it stays in channel counts

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #3691 (60e4dcb) into main (d6ac67f) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #3691   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          484       485    +1     
  Lines        26142     26147    +5     
=========================================
+ Hits         26142     26147    +5     
Impacted Files Coverage Δ
temba/msgs/migrations/0166_delete_from_counts.py 100.00% <100.00%> (ø)
temba/msgs/models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6ac67f...60e4dcb. Read the comment docs.

END IF;

IF OLD.broadcast_id IS NOT NULL AND OLD.delete_reason != 'A' THEN
PERFORM temba_insert_broadcastmsgcount(OLD.broadcast_id, -1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we use BroadcastMsgCount only (and incorrectly) for recipient_count when rendering broadcast created events in contact histories. Definitely doesn't feel necessary to decrement it when deleting messages and maybe it should be replaced with something that actually tracks recipients rather than msgs.

@rowanseymour rowanseymour marked this pull request as ready for review February 16, 2022 19:20
@rowanseymour rowanseymour merged commit 399a689 into main Feb 21, 2022
@rowanseymour rowanseymour deleted the msgs_always_delete_from_counts branch February 21, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants