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.
This commit is contained in:
Robin Ward 2019-06-03 09:08:39 -04:00
parent 5e61893cb2
commit f86a5bd5a9
1 changed files with 1 additions and 1 deletions

View File

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