discourse/lib/tasks/add_topic_to_quotes.rake

10 lines
342 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
desc "Add the topic to quotes"
2013-02-25 11:42:20 -05:00
task "add_topic_to_quotes" => :environment do
2013-02-05 14:16:51 -05: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