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
1 changed files with 20 additions and 12 deletions

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)
@ -22,7 +31,6 @@ task 'posts:rebake_uncooked_posts' => :environment do
puts "", "#{rebaked} posts done!", ""
end
end
desc 'Update each post with latest markdown and refresh oneboxes'
task 'posts:refresh_oneboxes' => :environment do