-
-
Notifications
You must be signed in to change notification settings - Fork 283
Open
Description
Instead of enqueuing jobs in a loop or sending emails in a loop, it is much more efficient to enqueue them all at once.
# bad
ids.each do |id|
SomeJob.perform_later(id)
end
# good
jobs = ids.map { |id| SomeJob.new(id) }
ActiveJob.perform_all_later(jobs)
Similar ActionMailer's deliver_all_later
. Possibly can also check for sidekiq's perform_bulk
.
I see a lot of places in my app where this is violated and recently improved a lot of code paths in terms of performance by using these methods.
I already have this cop implemented, so can contribute if accepted.
Metadata
Metadata
Assignees
Labels
No labels