fix comment bumping
This commit is contained in:
@@ -84,13 +84,19 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_last_commented_at
|
def update_last_commented_at
|
||||||
if Comment.where("post_id = ?", post_id).empty?
|
puts Comment.where("post_id = ?", post_id).count
|
||||||
execute_sql("UPDATE posts SET last_commented_at = null WHERE id = ?", post_id)
|
puts !do_not_bump_post?
|
||||||
elsif Comment.where("post_id = ?", post_id).count <= Danbooru.config.comment_threshold && !do_not_bump_post
|
if Comment.where("post_id = ?", post_id).count == 0
|
||||||
execute_sql("UPDATE posts SET last_commented_at = ? WHERE id = ?", created_at, post_id)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def do_not_bump_post?
|
||||||
|
do_not_bump_post == "1"
|
||||||
|
end
|
||||||
|
|
||||||
def vote!(score)
|
def vote!(score)
|
||||||
numerical_score = score == "up" ? 1 : -1
|
numerical_score = score == "up" ? 1 : -1
|
||||||
vote = votes.create(:score => numerical_score)
|
vote = votes.create(:score => numerical_score)
|
||||||
|
|||||||
Reference in New Issue
Block a user