don't count deleted comments for stories, update comment counts after comment del/undel

This commit is contained in:
joshua stein 2012-07-12 13:41:30 -05:00
commit 33e6eee4e0
2 changed files with 6 additions and 1 deletions

View file

@ -120,6 +120,8 @@ class Comment < ActiveRecord::Base
self.save(:validate => false)
Comment.record_timestamps = true
self.story.update_comment_count!
end
def undelete_for_user(user)
@ -130,6 +132,8 @@ class Comment < ActiveRecord::Base
self.save(:validate => false)
Comment.record_timestamps = true
self.story.update_comment_count!
end
def give_upvote_or_downvote_and_recalculate_confidence!(upvote, downvote)

View file

@ -303,6 +303,7 @@ class Story < ActiveRecord::Base
def update_comment_count!
Keystore.put("story:#{self.id}:comment_count",
Comment.where(:story_id => self.id).count)
Comment.where(:story_id => self.id, :is_moderated => 0,
:is_deleted => 0).count)
end
end