Skip to content

Commit

Permalink
FIX: import:rebake_uncooked_* jobs couldn't be run in parallel (dis…
Browse files Browse the repository at this point in the history
…course#25969)

If those jobs were started multiple times each process would have rebaked the same posts.
  • Loading branch information
gschlager authored Feb 29, 2024
1 parent 841b353 commit 6847ed5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/tasks/import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6847ed5

Please sign in to comment.