From 9f89aefdd3a7ea4053721c32f50d8289fdbbaa25 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 22 Sep 2015 12:19:02 -0400 Subject: [PATCH] FIX: Don't update the last poster when a whisper is made --- app/models/topic_featured_users.rb | 4 +++- lib/post_creator.rb | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/topic_featured_users.rb b/app/models/topic_featured_users.rb index d00aaeda1..ee461cbe6 100644 --- a/app/models/topic_featured_users.rb +++ b/app/models/topic_featured_users.rb @@ -38,6 +38,7 @@ WITH cte as ( JOIN posts p ON p.topic_id = t.id WHERE p.deleted_at IS NULL AND NOT p.hidden AND + p.post_type <> #{Post.types[:whisper]} AND p.user_id <> t.user_id AND p.user_id <> t.last_post_user_id #{filter} @@ -81,6 +82,7 @@ SQL private def update_participant_count - topic.update_columns(participant_count: topic.posts.count('distinct user_id')) + count = topic.posts.where('NOT hidden AND post_type <> ?', Post.types[:whisper]).count('distinct user_id') + topic.update_columns(participant_count: count) end end diff --git a/lib/post_creator.rb b/lib/post_creator.rb index 9b869749b..faf713fbe 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -273,6 +273,8 @@ class PostCreator end def update_topic_stats + return if @post.post_type == Post.types[:whisper] + attrs = { last_posted_at: @post.created_at, last_post_user_id: @post.user_id,