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:
Gerhard Schlager 2024-02-29 19:54:19 +01:00 committed by GitHub
parent 841b353d38
commit 6847ed5be6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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