From 6f8271c41238dd89c0cf01f409ae1ddcb10ce81f Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 8 May 2013 15:16:22 -0700 Subject: [PATCH] fix 014 --- script/fixes/014_note_ranges.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/script/fixes/014_note_ranges.rb b/script/fixes/014_note_ranges.rb index adbe220ab..dc8899712 100644 --- a/script/fixes/014_note_ranges.rb +++ b/script/fixes/014_note_ranges.rb @@ -9,21 +9,23 @@ Note.update_all("y = 0", "y < 0") Note.update_all("x = 0", "x > (select _.image_width from posts _ where _.id = notes.post_id limit 1)") Note.update_all("y = 0", "y > (select _.image_height from posts _ where _.id = notes.post_id limit 1)") -Note.where("x > (select _.image_width from posts _ where _.id = notes.id limit 1)").find_each do |note| - note.update_column(:x, note.versions.last.x) -end +# Note.where("x = 0").find_each do |note| +# note.update_column(:x, note.versions.last.x) if note.versions.last.x > 0 +# end -Note.where("y > (select _.image_height from posts _ where _.id = notes.id limit 1)").find_each do |note| - note.update_column(:y, note.versions.last.y) -end +# Note.where("y = 0").find_each do |note| +# note.update_column(:y, note.versions.last.y) if note.versions.last.y > 0 +# end Post.where("created_at >= '2013-02-01'").select("id, score, up_score, down_score").find_each do |post| 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) + revised_score = post.up_score + post.down_score + fav_count + puts "#{post.id}: #{post.score} -> #{revised_score}" if post.score != revised_score + post.update_column(:score, revised_score) 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) + post.flags.create!(:reason => "Unapproved in three days", :is_resolved => true) end end