mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
improve best filter so it properly excludes all admin messages from count as well
This commit is contained in:
parent
c4d8085fc5
commit
da6a88634b
2 changed files with 2 additions and 1 deletions
|
@ -25,6 +25,7 @@ class TopicView
|
||||||
@filtered_posts = @topic.posts
|
@filtered_posts = @topic.posts
|
||||||
@filtered_posts = @filtered_posts.with_deleted if user.try(:staff?)
|
@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.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?
|
if options[:username_filters].present?
|
||||||
usernames = options[:username_filters].map{|u| u.downcase}
|
usernames = options[:username_filters].map{|u| u.downcase}
|
||||||
|
@ -177,7 +178,6 @@ class TopicView
|
||||||
@index_offset = 0
|
@index_offset = 0
|
||||||
@posts = @filtered_posts.order('percent_rank asc, sort_order asc').where("post_number > 1")
|
@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.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 = @posts.to_a
|
||||||
@posts.sort!{|a,b| a.post_number <=> b.post_number}
|
@posts.sort!{|a,b| a.post_number <=> b.post_number}
|
||||||
@posts
|
@posts
|
||||||
|
|
|
@ -35,6 +35,7 @@ describe TopicView do
|
||||||
# should not get the status post
|
# should not get the status post
|
||||||
best = TopicView.new(topic.id, nil, best: 99)
|
best = TopicView.new(topic.id, nil, best: 99)
|
||||||
best.posts.count.should == 2
|
best.posts.count.should == 2
|
||||||
|
best.filtered_posts_count.should == 3
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue