don't count deleted comments for stories, update comment counts after comment del/undel
This commit is contained in:
parent
c685e03628
commit
33e6eee4e0
2 changed files with 6 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue