fixes #558
This commit is contained in:
@@ -6,6 +6,7 @@ class Comment < ActiveRecord::Base
|
|||||||
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
|
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
after_save :update_last_commented_at
|
after_save :update_last_commented_at
|
||||||
|
after_destroy :update_last_commented_at
|
||||||
attr_accessible :body, :post_id, :do_not_bump_post
|
attr_accessible :body, :post_id, :do_not_bump_post
|
||||||
attr_accessor :do_not_bump_post
|
attr_accessor :do_not_bump_post
|
||||||
|
|
||||||
@@ -83,8 +84,10 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_last_commented_at
|
def update_last_commented_at
|
||||||
if Comment.where(["post_id = ?", post_id]).count <= Danbooru.config.comment_threshold && !do_not_bump_post
|
if 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)
|
execute_sql("UPDATE posts SET last_commented_at = ? WHERE id = ?", created_at, post_id)
|
||||||
|
elsif Comment.where("post_id = ?", post_id).empty?
|
||||||
|
execute_sql("UPDATE posts SET last_commented_at = null WHERE id = ?", created_at, post_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user