From 786954e35b33e461e35a2c71ea6381726af6dede Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 2 Jun 2026 11:03:46 +0000 Subject: [PATCH] Fix pagination errors --- app/models/site_feed_annc.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/site_feed_annc.rb b/app/models/site_feed_annc.rb index 7f0832d..826f877 100644 --- a/app/models/site_feed_annc.rb +++ b/app/models/site_feed_annc.rb @@ -374,10 +374,11 @@ class SiteFeedAnnc pipeline_to_get_data << {"$sort"=>sort_maps} end - if max_len > 0 + if max_len > 0 && tags.blank? && hashtags.blank? pipeline_to_get_data << {"$limit"=> max_len} end + pipeline_to_get_count = pipeline.clone pipeline_to_get_count << {"$group" => { _id: nil, @@ -412,6 +413,7 @@ class SiteFeedAnnc if (tags.present? && tags != "all") || (hashtags.present? && hashtags != "all") feeds = feeds.uniq { |f| f['id'] } feeds_count = feeds.size + feeds = feeds.first(max_len) if max_len > 0 end return feeds, feeds_count