discourse/lib/tasks/add_topic_to_quotes.rake

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
390 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2013-02-06 03:16:51 +08:00
desc "Add the topic to quotes"
2013-02-26 00:42:20 +08:00
task "add_topic_to_quotes" => :environment do
2013-02-06 03:16:51 +08:00
Post
.where("raw like '%topic:%'")
.each do |p|
new_raw = p.raw.gsub(/topic:(\d+)\]/, "topic:#{p.topic_id}\"]")
new_cooked = p.cook(new_raw, topic_id: p.topic_id)
Post.update_all ["raw = ?, cooked = ?", new_raw, new_cooked], ["id = ?", p.id]
end
end