Merge branch 'master' of github.com:r888888888/danbooru
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
validate :validate_creator_is_not_limited
|
||||
validate :validate_creator_is_not_limited, :on => :create
|
||||
validates_format_of :body, :with => /\S/, :message => 'has no content'
|
||||
belongs_to :post
|
||||
belongs_to :creator, :class_name => "User"
|
||||
@@ -101,16 +101,19 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def update_last_commented_at_on_destroy
|
||||
if Comment.where("post_id = ? and id <> ?", post_id, id).count == 0
|
||||
Post.update_all("last_commented_at = NULL", ["id = ?", post_id])
|
||||
def update_last_commented_at_on_create
|
||||
if 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
|
||||
true
|
||||
end
|
||||
|
||||
def update_last_commented_at_on_create
|
||||
if 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])
|
||||
def update_last_commented_at_on_destroy
|
||||
other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order("id DESC")
|
||||
if other_comments.count == 0
|
||||
Post.update_all("last_commented_at = NULL", ["id = ?", post_id])
|
||||
else
|
||||
Post.update_all(["last_commented_at = ?", other_comments.first.created_at], ["id = ?", post_id])
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user