2013-02-05 14:16:51 -05:00
|
|
|
desc "walk all posts updating cooked with latest markdown"
|
2013-02-25 11:42:20 -05:00
|
|
|
task "posts:rebake" => :environment do
|
2013-02-05 14:16:51 -05:00
|
|
|
RailsMultisite::ConnectionManagement.each_connection do |db|
|
|
|
|
puts "Re baking post markdown for #{db} , changes are denoted with # , no change with ."
|
|
|
|
i = 0
|
2013-06-06 13:52:30 -04:00
|
|
|
Post.select([:id, :user_id, :cooked, :raw, :topic_id, :post_number]).each do |p|
|
2013-02-05 14:16:51 -05:00
|
|
|
i += 1
|
|
|
|
cooked = p.cook(p.raw, topic_id: p.topic_id)
|
|
|
|
if cooked != p.cooked
|
|
|
|
Post.exec_sql('update posts set cooked = ? where id = ?', cooked, p.id)
|
2013-06-06 13:52:30 -04:00
|
|
|
p.cooked = cooked
|
2013-02-05 14:16:51 -05:00
|
|
|
putc "#"
|
|
|
|
else
|
|
|
|
putc "."
|
|
|
|
end
|
2013-06-08 21:51:32 -04:00
|
|
|
TopicLink.extract_from(p)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
puts "#{i} posts done!"
|
|
|
|
puts "-----------------------------------------------"
|
|
|
|
puts
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|