don't count deleted comments towards user's comment count
This commit is contained in:
parent
5f04c3e52e
commit
b5f6ab36a8
|
@ -22,6 +22,8 @@ class Comment < ActiveRecord::Base
|
|||
:log_to_countinual
|
||||
after_destroy :unassign_votes
|
||||
|
||||
scope :active, -> { where(:is_deleted => false, :is_moderated => false) }
|
||||
|
||||
DOWNVOTABLE_DAYS = 7
|
||||
|
||||
# after this many minutes old, a comment cannot be edited
|
||||
|
@ -209,6 +211,7 @@ class Comment < ActiveRecord::Base
|
|||
Comment.record_timestamps = true
|
||||
|
||||
self.story.update_comments_count!
|
||||
self.user.update_comments_posted_count!
|
||||
end
|
||||
|
||||
def deliver_mention_notifications
|
||||
|
@ -456,5 +459,6 @@ class Comment < ActiveRecord::Base
|
|||
Comment.record_timestamps = true
|
||||
|
||||
self.story.update_comments_count!
|
||||
self.user.update_comments_posted_count!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -219,6 +219,10 @@ class User < ActiveRecord::Base
|
|||
Keystore.value_for("user:#{self.id}:comments_posted").to_i
|
||||
end
|
||||
|
||||
def update_comments_posted_count!
|
||||
Keystore.put("user:#{self.id}:comments_posted", self.comments.active.count)
|
||||
end
|
||||
|
||||
def delete!
|
||||
User.transaction do
|
||||
self.comments.each{|c| c.delete_for_user(self) }
|
||||
|
|
Loading…
Reference in a new issue