Story: make update_comment_count factor in deleted comments/threads
This commit is contained in:
parent
19ba94fd31
commit
048c614590
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue