Skip to content

Commit

Permalink
Accept null value for tracker removed data
Browse files Browse the repository at this point in the history
  • Loading branch information
say-yawn authored and groovecoder committed Jul 25, 2022
1 parent 0e1ff53 commit c71c65d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions emails/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ def emails_replied(self):
@property
def level_one_trackers_blocked(self):
return (
sum(ra.num_level_one_trackers_blocked for ra in self.relay_addresses)
+ sum(da.num_level_one_trackers_blocked for da in self.domain_addresses)
+ self.num_level_one_trackers_blocked_in_deleted_address
sum(ra.num_level_one_trackers_blocked or 0 for ra in self.relay_addresses)
+ sum(
da.num_level_one_trackers_blocked or 0 for da in self.domain_addresses
)
+ (self.num_level_one_trackers_blocked_in_deleted_address or 0)
)

@property
Expand Down Expand Up @@ -529,9 +531,9 @@ def delete(self, *args, **kwargs):
profile.num_address_deleted += 1
profile.num_email_forwarded_in_deleted_address += self.num_forwarded
profile.num_email_blocked_in_deleted_address += self.num_blocked
profile.num_level_one_trackers_blocked_in_deleted_address += (
self.num_level_one_trackers_blocked
)
profile.num_level_one_trackers_blocked_in_deleted_address = (
profile.num_level_one_trackers_blocked_in_deleted_address or 0
) + (self.num_level_one_trackers_blocked or 0)
profile.num_email_replied_in_deleted_address += self.num_replied
profile.num_email_spam_in_deleted_address += self.num_spam
profile.save()
Expand Down Expand Up @@ -707,9 +709,9 @@ def delete(self, *args, **kwargs):
profile.num_address_deleted += 1
profile.num_email_forwarded_in_deleted_address += self.num_forwarded
profile.num_email_blocked_in_deleted_address += self.num_blocked
profile.num_level_one_trackers_blocked_in_deleted_address += (
self.num_level_one_trackers_blocked
)
profile.num_level_one_trackers_blocked_in_deleted_address = (
profile.num_level_one_trackers_blocked_in_deleted_address or 0
) + (self.num_level_one_trackers_blocked or 0)
profile.num_email_replied_in_deleted_address += self.num_replied
profile.num_email_spam_in_deleted_address += self.num_spam
profile.save()
Expand Down
4 changes: 3 additions & 1 deletion emails/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,9 @@ def _sns_message(message_json):
f"{settings.SITE_ORIGIN}/tracker-report/#"
+ json.dumps(tracker_report_details)
)
address.num_level_one_trackers_blocked += removed_count
address.num_level_one_trackers_blocked = (
address.num_level_one_trackers_blocked or 0
) + removed_count
address.save()

wrapped_html = wrap_html_email(
Expand Down

0 comments on commit c71c65d

Please sign in to comment.