From da6a88634b502ee86fe65b2cfa12c41e2a8da934 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 22 May 2013 15:14:47 +1000 Subject: [PATCH] improve best filter so it properly excludes all admin messages from count as well --- lib/topic_view.rb | 2 +- spec/components/topic_view_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index d221035b3b0..63d7428abf0 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -25,6 +25,7 @@ class TopicView @filtered_posts = @topic.posts @filtered_posts = @filtered_posts.with_deleted if user.try(:staff?) @filtered_posts = @filtered_posts.best_of if options[:best_of].present? + @filtered_posts = @filtered_posts.where('posts.post_type <> ?', Post.types[:moderator_action]) if options[:best].present? if options[:username_filters].present? usernames = options[:username_filters].map{|u| u.downcase} @@ -177,7 +178,6 @@ class TopicView @index_offset = 0 @posts = @filtered_posts.order('percent_rank asc, sort_order asc').where("post_number > 1") @posts = @posts.includes(:reply_to_user).includes(:topic).joins(:user).limit(max) - @posts = @posts.where('posts.post_type <> ?', Post.types[:moderator_action]) @posts = @posts.to_a @posts.sort!{|a,b| a.post_number <=> b.post_number} @posts diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb index 350a36f0b15..c232cb189dc 100644 --- a/spec/components/topic_view_spec.rb +++ b/spec/components/topic_view_spec.rb @@ -35,6 +35,7 @@ describe TopicView do # should not get the status post best = TopicView.new(topic.id, nil, best: 99) best.posts.count.should == 2 + best.filtered_posts_count.should == 3 end