From 04b004d2a4ec17024dd79b8b5ec9ae39ed07a82b Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 27 Sep 2022 21:57:55 -0500 Subject: [PATCH] Fix #4586: Wrong paginator for status:unmoderated Don't cache the page count for status:unmoderated, status:modqueue, status:pending, status:flagged, or status:appealed searches. Before the page count was cached for 5 minutes, which could quickly become out of date as a user went through the modqueue. After bd21b4a86, they're now fast enough that we no longer need to cache them. --- app/logical/post_query.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/logical/post_query.rb b/app/logical/post_query.rb index 457b40911..2a3f08fc5 100644 --- a/app/logical/post_query.rb +++ b/app/logical/post_query.rb @@ -216,19 +216,21 @@ class PostQuery # @return [Integer, nil] The number of posts, or nil on timeout. def fast_count(timeout: 1_000, estimate_count: true, skip_cache: false) count = nil - count = estimated_count if estimate_count + count = estimated_count(timeout) if estimate_count count = cached_count(timeout) if count.nil? && !skip_cache count = exact_count(timeout) if count.nil? && skip_cache count end - def estimated_count + def estimated_count(timeout = 1_000) if is_empty_search? estimated_row_count elsif is_simple_tag? tag.try(:post_count) elsif is_metatag?(:rating) estimated_row_count + elsif (is_metatag?(:status) || is_metatag?(:is)) && metatags.sole.value.in?(%w[pending flagged appealed modqueue unmoderated]) + exact_count(timeout) elsif is_metatag?(:pool) || is_metatag?(:ordpool) name = find_metatag(:pool, :ordpool) Pool.find_by_name(name)&.post_count || 0