]> cat aescling's git repositories - mastodon.git/blobdiff - app/workers/scheduler/email_scheduler.rb
Fix configuration for sidekiq-unique-jobs after 7.x upgrade (#15908)
[mastodon.git] / app / workers / scheduler / email_scheduler.rb
index 24117e4241865766d050740645bfc4e4427284eb..c052f2fce08c4de199ae7ce483d41ae644501285 100644 (file)
@@ -3,7 +3,10 @@
 class Scheduler::EmailScheduler
   include Sidekiq::Worker
 
-  sidekiq_options unique: :until_executed
+  sidekiq_options retry: 0
+
+  FREQUENCY      = 7.days.freeze
+  SIGN_IN_OFFSET = 1.day.freeze
 
   def perform
     eligible_users.reorder(nil).find_each do |user|
@@ -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
This page took 0.05265 seconds and 3 git commands to generate.