A platform for community discussion. Free, open, simple.
FIX: Topic map was incorrectly counting assign actions (#10360)
Kane York13feb300a897
diff --git a/lib/topic_view.rb b/lib/topic_view.rbindex b2f37ccf616..537a53fccc5 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -366,11 +366,6 @@ class TopicViewif is_mega_topic?{}else- post_types = [Post.types[:regular], Post.types[:moderator_action]]- if @guardian.can_see_whispers?(@topic)- post_types << Post.types[:whisper]- end-sql = <<~SQLSELECT user_id, count(*) AS count_allFROM posts@@ -378,12 +373,13 @@ class TopicViewAND post_type IN (:post_types)AND user_id IS NOT NULLAND posts.deleted_at IS NULL+ AND action_code IS NULLGROUP BY user_idORDER BY count_all DESCLIMIT #{MAX_PARTICIPANTS}SQL- Hash[*DB.query_single(sql, topic_id: @topic.id, post_types: post_types)]+ Hash[*DB.query_single(sql, topic_id: @topic.id, post_types: Topic.visible_post_types(@guardian&.user))]endendenddiff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rbindex 0d51b1ef3fa..508ba36fc6d 100644--- a/spec/components/topic_view_spec.rb+++ b/spec/components/topic_view_spec.rb@@ -286,6 +286,8 @@ describe TopicView docontext '.post_counts_by_user' doit 'returns the two posters with their appropriate counts' doFabricate(:post, topic: topic, user: evil_trout, post_type: Post.types[:whisper])+ # Should not be counted+ Fabricate(:post, topic: topic, user: evil_trout, post_type: Post.types[:whisper], action_code: 'assign')expect(TopicView.new(topic.id, admin).post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [evil_trout.id, 2]])