Ensure that we restore the site setting in posts:rebake rake task.
This commit is contained in:
parent
875008522d
commit
59a2767de8
|
@ -81,22 +81,24 @@ end
|
|||
def rebake_posts(opts = {})
|
||||
puts "Rebaking post markdown for '#{RailsMultisite::ConnectionManagement.current_db}'"
|
||||
|
||||
disable_edit_notifications = SiteSetting.disable_edit_notifications
|
||||
SiteSetting.disable_edit_notifications = true
|
||||
begin
|
||||
disable_edit_notifications = SiteSetting.disable_edit_notifications
|
||||
SiteSetting.disable_edit_notifications = true
|
||||
|
||||
total = Post.count
|
||||
rebaked = 0
|
||||
total = Post.count
|
||||
rebaked = 0
|
||||
|
||||
# TODO: make this resumable because carrying around 20 million ids in memory is not a great idea long term
|
||||
Post.order(id: :desc).pluck(:id).in_groups_of(1000, false).each do |batched_post_ids|
|
||||
Post.order(created_at: :desc).where(id: batched_post_ids).each do |post|
|
||||
rebake_post(post, opts)
|
||||
print_status(rebaked += 1, total)
|
||||
# TODO: make this resumable because carrying around 20 million ids in memory is not a great idea long term
|
||||
Post.order(id: :desc).pluck(:id).in_groups_of(1000, false).each do |batched_post_ids|
|
||||
Post.order(created_at: :desc).where(id: batched_post_ids).each do |post|
|
||||
rebake_post(post, opts)
|
||||
print_status(rebaked += 1, total)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
SiteSetting.disable_edit_notifications = disable_edit_notifications
|
||||
end
|
||||
|
||||
SiteSetting.disable_edit_notifications = disable_edit_notifications
|
||||
|
||||
puts "", "#{rebaked} posts done!", "-" * 50
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue