fix comment bumping

This commit is contained in:
albert
2013-02-26 21:54:18 -08:00
parent b1f595fa6f
commit e86dda1b50

View File

@@ -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)