Adds logic to send proposal notifications in batches

WIP batches tests
This commit is contained in:
María Checa
2018-05-24 17:53:16 +02:00
committed by decabeza
parent 9264763ec5
commit b7a1599fdf
6 changed files with 150 additions and 6 deletions

View File

@@ -68,4 +68,29 @@ class Notification < ActiveRecord::Base
end
end
def self.send_pending
run_at = first_batch_run_at
User.email_digest.find_in_batches(batch_size: batch_size) do |users|
users.each do |user|
email_digest = EmailDigest.new(user)
email_digest.deliver(run_at)
end
run_at += batch_interval
end
end
private
def self.batch_size
10000
end
def self.batch_interval
20.minutes
end
def self.first_batch_run_at
Time.current
end
end