From 88ca51bb0037672d5daaa35df59624030a7c3644 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 5 Jul 2013 16:58:43 -0400 Subject: [PATCH] FIX: Wordpress route wasn't updating filter count correctly --- lib/topic_view.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index b8514445307..e0d5d7e0aac 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -161,6 +161,13 @@ class TopicView return end + + if opts[:only_moderator_liked] + liked_by_moderators = PostAction.where(post_id: @filtered_posts.pluck(:id), post_action_type_id: PostActionType.types[:like]) + liked_by_moderators = liked_by_moderators.joins(:user).where('users.moderator').pluck(:post_id) + @filtered_posts = @filtered_posts.where(id: liked_by_moderators) + end + @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) @@ -184,12 +191,6 @@ class TopicView @posts = @posts.where('posts.score >= ?', min_score) end - if opts[:only_moderator_liked] - liked_by_moderators = PostAction.where(post_id: @filtered_posts.pluck(:id), post_action_type_id: PostActionType.types[:like]) - liked_by_moderators = liked_by_moderators.joins(:user).where('users.moderator').pluck(:post_id) - @posts = @posts.where(id: liked_by_moderators) - end - @posts = @posts.to_a @posts.sort!{|a,b| a.post_number <=> b.post_number} @posts