DEV: Allow rebaking oncooked posts of single site

This commit is contained in:
Gerhard Schlager 2019-06-04 15:12:34 +02:00
parent 4fe885dedf
commit fb121815a5

View File

@ -8,7 +8,16 @@ task 'posts:rebake' => :environment do
end
task 'posts:rebake_uncooked_posts' => :environment do
RailsMultisite::ConnectionManagement.each_connection do
ENV['RAILS_DB'] ? rebake_uncooked_posts : rebake_uncooked_posts_all_sites
end
def rebake_uncooked_posts_all_sites
RailsMultisite::ConnectionManagement.each_connection do |db|
rebake_uncooked_posts
end
end
def rebake_uncooked_posts
puts "Rebaking uncooked posts on #{RailsMultisite::ConnectionManagement.current_db}"
uncooked = Post.where('baked_version <> ? or baked_version IS NULL', Post::BAKED_VERSION)
@ -21,7 +30,6 @@ task 'posts:rebake_uncooked_posts' => :environment do
end
puts "", "#{rebaked} posts done!", ""
end
end
desc 'Update each post with latest markdown and refresh oneboxes'