From c944d5315ace1f685ff6537ad24ff3d6c30002de Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 7 May 2013 13:49:25 -0700 Subject: [PATCH] add fix for empty post flags --- script/fixes/014_note_ranges.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/script/fixes/014_note_ranges.rb b/script/fixes/014_note_ranges.rb index 2727b119a..884ff7a46 100644 --- a/script/fixes/014_note_ranges.rb +++ b/script/fixes/014_note_ranges.rb @@ -10,6 +10,12 @@ Note.update_all("x = 0", "x > (select _.image_width from posts _ where _.id = no Note.update_all("y = 0", "y > (select _.image_height from posts _ where _.id = notes.id limit 1)") Post.where("created_at >= '2013-02-01'").select("id, score, up_score, down_score").find_each do |post| - fav_count = - post.update_column(:score, post.up_score + post.down_score) + fav_count = Favorite.where("post_id = #{post.id}").joins("join users on favorites.user_id = users.id").where("users.level >= ?", User::Levels::GOLD).count + post.update_column(:score, post.up_score + post.down_score + fav_count) end ; true + +Post.where("is_deleted = true and created_at >= '2013-02-01'").find_each do |post| + if post.flags.empty? + post.flags.create(:reason => "Unapproved in three days", :is_resolved => true) + end +end