Skip to content

Commit

Permalink
improve best filter so it properly excludes all admin messages from c…
Browse files Browse the repository at this point in the history
…ount as well
  • Loading branch information
SamSaffron committed May 22, 2013
1 parent c4d8085 commit da6a886
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/topic_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def initialize(topic_id, user=nil, options={})
@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}
Expand Down Expand Up @@ -177,7 +178,6 @@ def filter_best(max)
@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
Expand Down
1 change: 1 addition & 0 deletions spec/components/topic_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# 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

Expand Down

0 comments on commit da6a886

Please sign in to comment.