PERF: rake posts:rebake_uncooked_posts runs inline

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.

diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 5062012..5bcdf29 100644
--- a/lib/tasks/posts.rake
+++ b/lib/tasks/posts.rake
@@ -8,6 +8,11 @@ task 'posts:rebake' => :environment do
 end
 
 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
 end
 
@@ -24,8 +29,18 @@ def rebake_uncooked_posts
   rebaked = 0
   total = 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

GitHub sha: 7632fe0b