mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FEATURE: Add rake task to mark old hashtag format for rebake (#19876)
Since the new hashtag format has been added, we want site admins to be able to rebake old posts with the old hashtag format. This can now be done with `rake hashtags:mark_old_format_for_rebake` which goes and marks posts with the old cooked version of hashtags in this format for rebake: ``` <a class=\"hashtag\" href=\"/c/ux/14\">#<span>ux</span></a> ``` c.f. https://meta.discourse.org/t/what-rebake-is-required-for-the-new-autocomplete-styling/249642/12
This commit is contained in:
15
lib/tasks/hashtags.rake
Normal file
15
lib/tasks/hashtags.rake
Normal file
@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
desc "Mark posts with the old hashtag cooked format (pre enable_experimental_hashtag_autocomplete) for rebake"
|
||||
task "hashtags:mark_old_format_for_rebake" => :environment do
|
||||
# See Post#rebake_old, which is called via the PeriodicalUpdates job
|
||||
# on a schedule.
|
||||
puts "Finding posts matching old format, this could take some time..."
|
||||
posts_to_rebake = Post.where("cooked like '%class=\"hashtag\"%'")
|
||||
STDOUT.puts(
|
||||
"[!] You are about to mark #{posts_to_rebake.count} posts containing hashtags in the old format to rebake. [CTRL+c] to cancel, [ENTER] to continue",
|
||||
)
|
||||
STDIN.gets.chomp if !Rails.env.test?
|
||||
posts_to_rebake.update_all(baked_version: 0)
|
||||
puts "Done, rebakes will happen when periodal updates job runs."
|
||||
end
|
Reference in New Issue
Block a user