FIX: Rake task executed wrong method (#25323)

Rake files share methods with all other rake files and there is already a `rebake_posts` method in another rake file.
This commit is contained in:
Gerhard Schlager 2024-01-19 12:55:24 +01:00 committed by GitHub
parent 2815fc24ff
commit a417760337
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -735,7 +735,7 @@ task "import:rebake_uncooked_posts_with_polls" => :environment do
posts = Post.where("EXISTS (SELECT 1 FROM polls WHERE polls.post_id = posts.id)") posts = Post.where("EXISTS (SELECT 1 FROM polls WHERE polls.post_id = posts.id)")
rebake_posts(posts) import_rebake_posts(posts)
end end
desc "Rebake posts that contain events" desc "Rebake posts that contain events"
@ -747,7 +747,7 @@ task "import:rebake_uncooked_posts_with_events" => :environment do
"EXISTS (SELECT 1 FROM discourse_post_event_events WHERE discourse_post_event_events.id = posts.id)", "EXISTS (SELECT 1 FROM discourse_post_event_events WHERE discourse_post_event_events.id = posts.id)",
) )
rebake_posts(posts) import_rebake_posts(posts)
end end
desc "Rebake posts that have tag" desc "Rebake posts that have tag"
@ -760,21 +760,21 @@ task "import:rebake_uncooked_posts_with_tag", [:tag_name] => :environment do |_t
args[:tag_name], args[:tag_name],
) )
rebake_posts(posts) import_rebake_posts(posts)
end end
def rebake_posts(posts) def import_rebake_posts(posts)
Jobs.run_immediately! Jobs.run_immediately!
OptimizedImage.lock_per_machine = false OptimizedImage.lock_per_machine = false
posts = posts.where("baked_version <> ? or baked_version IS NULL", Post::BAKED_VERSION)
max_count = posts.count max_count = posts.count
current_count = 0 current_count = 0
posts posts.find_each(order: :desc) do |post|
.where("baked_version <> ? or baked_version IS NULL", Post::BAKED_VERSION) post.rebake!
.find_each(order: :desc) do |post| current_count += 1
post.rebake! print "\r%7d / %7d" % [current_count, max_count]
current_count += 1 end
print "\r%7d / %7d" % [current_count, max_count]
end
end end