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,22 +8,30 @@ task 'posts:rebake' => :environment do
end end
task 'posts:rebake_uncooked_posts' => :environment do task 'posts:rebake_uncooked_posts' => :environment do
RailsMultisite::ConnectionManagement.each_connection do ENV['RAILS_DB'] ? rebake_uncooked_posts : rebake_uncooked_posts_all_sites
puts "Rebaking uncooked posts on #{RailsMultisite::ConnectionManagement.current_db}" end
uncooked = Post.where('baked_version <> ? or baked_version IS NULL', Post::BAKED_VERSION)
rebaked = 0 def rebake_uncooked_posts_all_sites
total = uncooked.count RailsMultisite::ConnectionManagement.each_connection do |db|
rebake_uncooked_posts
uncooked.find_each do |post|
rebake_post(post)
print_status(rebaked += 1, total)
end
puts "", "#{rebaked} posts done!", ""
end end
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)
rebaked = 0
total = uncooked.count
uncooked.find_each do |post|
rebake_post(post)
print_status(rebaked += 1, total)
end
puts "", "#{rebaked} posts done!", ""
end
desc 'Update each post with latest markdown and refresh oneboxes' desc 'Update each post with latest markdown and refresh oneboxes'
task 'posts:refresh_oneboxes' => :environment do task 'posts:refresh_oneboxes' => :environment do
ENV['RAILS_DB'] ? rebake_posts(invalidate_oneboxes: true) : rebake_posts_all_sites(invalidate_oneboxes: true) ENV['RAILS_DB'] ? rebake_posts(invalidate_oneboxes: true) : rebake_posts_all_sites(invalidate_oneboxes: true)