Story: make update_comment_count factor in deleted comments/threads

This commit is contained in:
joshua stein 2012-12-30 12:12:24 -06:00
parent 19ba94fd31
commit 048c614590

View file

@ -391,8 +391,10 @@ class Story < ActiveRecord::Base
end
def update_comment_count!
Keystore.put("story:#{self.id}:comment_count",
Comment.where(:story_id => self.id, :is_deleted => 0,
:is_moderated => 0).count)
# calculate count after removing deleted comments and threads
alive_count = Comment.ordered_for_story_or_thread_for_user(self.id, nil,
nil).select{|c| !c.is_gone? }.count
Keystore.put("story:#{self.id}:comment_count", alive_count)
end
end