mirror of
https://github.com/discourse/discourse.git
synced 2026-08-13 06:25:11 -05:00
PERF: Do not enqueue digest emails when attempted recently (#10849)
Previously, Jobs::EnqueueDigestEmails would enqueue a digest job for every user, even if there are no topics to send. The digest job would exit, no email would send, and last_emailed_at would not change. 30 minutes later, Jobs::EnqueueDigestEmails would run again and re-enqueue jobs for the same users.120fa8adintroduced a temporary mitigation for this issue, by randomly selecting a subset of those users each time. This commit adds a new `digest_attempted_at` column to the `user_stats` table. This column is updated every time a digest job completes for a user. Using this, we can avoid scheduling digest jobs for the same user every 30 minutes. This also removes the random user selection in120fa8ad, and instead prioritizes users who had digests attempted the longest time ago.
This commit is contained in:
@@ -290,4 +290,5 @@ end
|
||||
# flags_ignored :integer default(0), not null
|
||||
# first_unread_at :datetime not null
|
||||
# distinct_badge_count :integer default(0), not null
|
||||
# digest_attempted_at :datetime
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user