A platform for community discussion. Free, open, simple.
PERF: rake posts:rebake_uncooked_posts runs inline
Sam Saffron7632fe0b58a1
diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rakeindex 506201211f3..5bcdf2983e8 100644--- a/lib/tasks/posts.rake+++ b/lib/tasks/posts.rake@@ -8,6 +8,11 @@ task 'posts:rebake' => :environment doendtask '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_sitesend@@ -24,8 +29,18 @@ def rebake_uncooked_postsrebaked = 0total = uncooked.count- uncooked.find_each do |post|- rebake_post(post)+ ids = uncooked.pluck(:id)+ # 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)end