Skip to content

Commit

Permalink
FIX: Rake task executed wrong method (discourse#25323)
Browse files Browse the repository at this point in the history
Rake files share methods with all other rake files and there is already a `rebake_posts` method in another rake file.
  • Loading branch information
gschlager authored Jan 19, 2024
1 parent 2815fc2 commit a417760
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/tasks/import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

rebake_posts(posts)
import_rebake_posts(posts)
end

desc "Rebake posts that contain events"
Expand All @@ -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)",
)

rebake_posts(posts)
import_rebake_posts(posts)
end

desc "Rebake posts that have tag"
Expand All @@ -760,21 +760,21 @@ task "import:rebake_uncooked_posts_with_tag", [:tag_name] => :environment do |_t
args[:tag_name],
)

rebake_posts(posts)
import_rebake_posts(posts)
end

def rebake_posts(posts)
def import_rebake_posts(posts)
Jobs.run_immediately!
OptimizedImage.lock_per_machine = false

posts = posts.where("baked_version <> ? or baked_version IS NULL", Post::BAKED_VERSION)

max_count = posts.count
current_count = 0

posts
.where("baked_version <> ? or baked_version IS NULL", Post::BAKED_VERSION)
.find_each(order: :desc) do |post|
post.rebake!
current_count += 1
print "\r%7d / %7d" % [current_count, max_count]
end
posts.find_each(order: :desc) do |post|
post.rebake!
current_count += 1
print "\r%7d / %7d" % [current_count, max_count]
end
end

0 comments on commit a417760

Please sign in to comment.