mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:42:45 +08:00
FIX: import:rebake_uncooked_*
jobs couldn't be run in parallel (#25969)
If those jobs were started multiple times each process would have rebaked the same posts.
This commit is contained in:
parent
841b353d38
commit
6847ed5be6
|
@ -772,8 +772,15 @@ def import_rebake_posts(posts)
|
|||
max_count = posts.count
|
||||
current_count = 0
|
||||
|
||||
posts.find_each(order: :desc) do |post|
|
||||
post.rebake!
|
||||
ids = posts.pluck(:id)
|
||||
# work randomly so you can run this job from lots of consoles if needed
|
||||
ids.shuffle!
|
||||
|
||||
ids.each do |id|
|
||||
# may have been cooked in interim
|
||||
post = posts.where(id: id).first
|
||||
post.rebake! if post
|
||||
|
||||
current_count += 1
|
||||
print "\r%7d / %7d" % [current_count, max_count]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user