Commit ab650e7c authored by Sean McGivern's avatar Sean McGivern

Use `bulk_perform_async` to schedule issue due emails

parent fd4a0820
...@@ -3,8 +3,8 @@ class IssueDueSchedulerWorker ...@@ -3,8 +3,8 @@ class IssueDueSchedulerWorker
include CronjobQueue include CronjobQueue
def perform def perform
Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).each do |project_id| project_ids = Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).map { |id| [id] }
MailScheduler::IssueDueWorker.perform_async(project_id)
end MailScheduler::IssueDueWorker.bulk_perform_async(project_ids)
end end
end end
...@@ -14,8 +14,7 @@ describe IssueDueSchedulerWorker do ...@@ -14,8 +14,7 @@ describe IssueDueSchedulerWorker do
create(:issue, :closed, project: project_closed_issue, due_date: Date.tomorrow) create(:issue, :closed, project: project_closed_issue, due_date: Date.tomorrow)
create(:issue, :opened, project: project_issue_due_another_day, due_date: Date.today) create(:issue, :opened, project: project_issue_due_another_day, due_date: Date.today)
expect(MailScheduler::IssueDueWorker).to receive(:perform_async).with(project1.id) expect(MailScheduler::IssueDueWorker).to receive(:bulk_perform_async).with([[project1.id], [project2.id]])
expect(MailScheduler::IssueDueWorker).to receive(:perform_async).with(project2.id)
described_class.new.perform described_class.new.perform
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment