FIX: Wordpress route wasn't updating filter count correctly

This commit is contained in:
Robin Ward 2013-07-05 16:58:43 -04:00
parent 25d2cbc33f
commit 88ca51bb00
1 changed files with 7 additions and 6 deletions

View File

@ -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