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

Incorrect alert sending logic means that some failed alerts never get re-tried #4804

Open
evansd opened this issue May 24, 2024 · 0 comments

Comments

@evansd
Copy link
Collaborator

evansd commented May 24, 2024

The send_monthly_alerts command contains logic to avoid re-sending alerts which have already been sent. However this works by checking whether the user has been send any alerts for the current month, rather than whether they've been sent an alert for the specific bookmark:

query = (
Q(user__is_active=True)
& ~Q(user__emailmessage__tags__contains=["measures", now_month])
&

This means that if some, but not all, of a user's alerts get sent successfully then subsequent runs of the command will never try to resend the failed ones.

There's no way to fix this without a db migration because the current EmailMessage object has no link back to its source bookmark object:

class EmailMessage(models.Model):
message_id = models.CharField(max_length=998, primary_key=True)
pickled_message = models.BinaryField()
to = ArrayField(models.CharField(max_length=254, db_index=True))
subject = models.CharField(max_length=200)
tags = ArrayField(models.CharField(max_length=100, db_index=True), null=True)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE)
send_count = models.SmallIntegerField(default=0)

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

No branches or pull requests

1 participant