From e86dda1b50468515ae82ab980b3af712c1d8dd7f Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 26 Feb 2013 21:54:18 -0800 Subject: [PATCH] fix comment bumping --- app/models/comment.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 8e5141f3b..ff3aa2272 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -84,13 +84,19 @@ class Comment < ActiveRecord::Base end def update_last_commented_at - if Comment.where("post_id = ?", post_id).empty? - execute_sql("UPDATE posts SET last_commented_at = null WHERE id = ?", post_id) - elsif Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post - execute_sql("UPDATE posts SET last_commented_at = ? WHERE id = ?", created_at, post_id) + puts Comment.where("post_id = ?", post_id).count + puts !do_not_bump_post? + if Comment.where("post_id = ?", post_id).count == 0 + Post.update_all("last_commented_at = NULL", ["id = ?", post_id]) + elsif Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post? + Post.update_all(["last_commented_at = ?", created_at], ["id = ?", post_id]) end end + def do_not_bump_post? + do_not_bump_post == "1" + end + def vote!(score) numerical_score = score == "up" ? 1 : -1 vote = votes.create(:score => numerical_score)