FEATURE: multisite support for posts:rebake_uncooked_posts

FEATURE: multisite support for posts:rebake_uncooked_posts

diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 93f149e..f20f961 100644
--- a/lib/tasks/posts.rake
+++ b/lib/tasks/posts.rake
@@ -8,17 +8,20 @@ task 'posts:rebake' => :environment do
 end
 
 task 'posts:rebake_uncooked_posts' => :environment do
-  uncooked = Post.where('baked_version <> ? or baked_version IS NULL', Post::BAKED_VERSION)
+  RailsMultisite::ConnectionManagement.each_connection do
+    puts "Rebaking uncooked posts on #{RailsMultisite::ConnectionManagement.current_db}"
+    uncooked = Post.where('baked_version <> ? or baked_version IS NULL', Post::BAKED_VERSION)
 
-  rebaked = 0
-  total = uncooked.count
+    rebaked = 0
+    total = uncooked.count
 
-  uncooked.find_each do |post|
-    rebake_post(post)
-    print_status(rebaked += 1, total)
-  end
+    uncooked.find_each do |post|
+      rebake_post(post)
+      print_status(rebaked += 1, total)
+    end
 
-  puts "", "#{rebaked} posts done!", ""
+    puts "", "#{rebaked} posts done!", ""
+  end
 end
 
 desc 'Update each post with latest markdown and refresh oneboxes'

GitHub sha: d6daa60d

1 Like