Use peform_bulk in Article#before_destroy_actions (#16326)

This commit is contained in:
Michael Kohl 2022-01-28 10:09:51 +07:00 committed by GitHub
parent 48c1942e76
commit 0d2e05857d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -621,9 +621,10 @@ class Article < ApplicationRecord
article_ids.concat organization.article_ids
end
# perform busting cache in chunks in case there're a lot of articles
(article_ids.uniq.sort - [id]).each_slice(10) do |ids|
Articles::BustMultipleCachesWorker.perform_async(ids)
end
# NOTE: `perform_bulk` takes an array of arrays as argument. Since the worker
# takes an array of ids as argument, this becomes triple-nested.
job_params = (article_ids.uniq.sort - [id]).each_slice(10).to_a.map { |ids| [ids] }
Articles::BustMultipleCachesWorker.perform_bulk(job_params)
end
def evaluate_front_matter(front_matter)