From f86a5bd5a9e603a71c1b95e71805b0f2044c85d0 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 3 Jun 2019 09:08:39 -0400 Subject: [PATCH] FIX: Regression with finding reviewable counts on topics This was a fairly serious regression on sites with large (mega) topics, however it was limited to staff. The issue here is the query was using filtered_post_ids which I'd assumed was already windowed to the current page, when in fact it was all the ids in the topic. This fix corrects it by using the correct windowed collection. --- lib/topic_view.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index e9b125050d8..57b7585e564 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -424,7 +424,7 @@ class TopicView # Create a hash with counts by post so we can quickly look up whether there is reviewable content. @reviewable_counts = {} Reviewable. - where(target_type: 'Post', target_id: filtered_post_ids). + where(target_type: 'Post', target_id: @posts.map(&:id)). includes(:reviewable_scores).each do |r| for_post = (@reviewable_counts[r.target_id] ||= { total: 0, pending: 0, reviewable_id: r.id })