mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
PERF: rake posts:rebake_uncooked_posts runs inline
Running this inline makes more sense otherwise there is extreme risk in saturating sidekiq queue. This also reworks ordering and selection so we double check if a post needs rebaking prior to rebaking, this unlocks the ability to run this rake task from multiple consoles.
This commit is contained in:
parent
213b7d19d9
commit
7632fe0b58
@ -8,6 +8,11 @@ task 'posts:rebake' => :environment do
|
|||||||
end
|
end
|
||||||
|
|
||||||
task 'posts:rebake_uncooked_posts' => :environment do
|
task 'posts:rebake_uncooked_posts' => :environment do
|
||||||
|
# rebaking uncooked posts can very quickly saturate sidekiq
|
||||||
|
# this provides an insurance policy so you can safely run and stop
|
||||||
|
# this rake task without worrying about your sidekiq imploding
|
||||||
|
Jobs.run_immediately!
|
||||||
|
|
||||||
ENV['RAILS_DB'] ? rebake_uncooked_posts : rebake_uncooked_posts_all_sites
|
ENV['RAILS_DB'] ? rebake_uncooked_posts : rebake_uncooked_posts_all_sites
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -24,8 +29,18 @@ def rebake_uncooked_posts
|
|||||||
rebaked = 0
|
rebaked = 0
|
||||||
total = uncooked.count
|
total = uncooked.count
|
||||||
|
|
||||||
uncooked.find_each do |post|
|
ids = uncooked.pluck(:id)
|
||||||
rebake_post(post)
|
# work randomly so you can run this job from lots of consoles if needed
|
||||||
|
ids.shuffle!
|
||||||
|
|
||||||
|
ids.each do |id|
|
||||||
|
# may have been cooked in interim
|
||||||
|
post = uncooked.where(id: id).first
|
||||||
|
|
||||||
|
if post
|
||||||
|
rebake_post(post)
|
||||||
|
end
|
||||||
|
|
||||||
print_status(rebaked += 1, total)
|
print_status(rebaked += 1, total)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user