about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-01-02 10:47:32 +0100
committerGitHub <noreply@github.com>2019-01-02 10:47:32 +0100
commit66436d08959998be20c6c6bf631177d8c1f3e0d1 (patch)
treee9d8fd6b53006cbf2c12418a9ebfa6e46a1be617 /app/workers
parentdc84899fffbee254454e88f3d78848eb6c51beeb (diff)
Improve e-mail digest (#9689)
- Reduce time-to-digest from 20 to 7 days
- Fetch mentions starting from +1 day since last login
- Fix case when last login is more recent than last e-mail
- Do not render all mentions, only 40, but show number in subject
- Do not send digest to moved accounts
- Do send digest to silenced accounts
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/scheduler/email_scheduler.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/workers/scheduler/email_scheduler.rb b/app/workers/scheduler/email_scheduler.rb
index 24ec89b29..1eeeee412 100644
--- a/app/workers/scheduler/email_scheduler.rb
+++ b/app/workers/scheduler/email_scheduler.rb
@@ -5,6 +5,9 @@ class Scheduler::EmailScheduler
 
   sidekiq_options unique: :until_executed, retry: 0
 
+  FREQUENCY      = 7.days.freeze
+  SIGN_IN_OFFSET = 1.day.freeze
+
   def perform
     eligible_users.reorder(nil).find_each do |user|
       next unless user.allows_digest_emails?
@@ -15,11 +18,8 @@ class Scheduler::EmailScheduler
   private
 
   def eligible_users
-    User.confirmed
-        .joins(:account)
-        .where(accounts: { silenced: false, suspended: false })
-        .where(disabled: false)
-        .where('current_sign_in_at < ?', 20.days.ago)
-        .where('last_emailed_at IS NULL OR last_emailed_at < ?', 20.days.ago)
+    User.emailable
+        .where('current_sign_in_at < ?', (FREQUENCY + SIGN_IN_OFFSET).ago)
+        .where('last_emailed_at IS NULL OR last_emailed_at < ?', FREQUENCY.ago)
   end
 end