From 93ff42af466abb51f9881fac26507731283dfebd Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 15 Oct 2024 05:18:48 +0000 Subject: [PATCH] fix error for mongo version smaller than 3.4 --- app/models/site_feed_annc.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/site_feed_annc.rb b/app/models/site_feed_annc.rb index 9626394..9952b79 100644 --- a/app/models/site_feed_annc.rb +++ b/app/models/site_feed_annc.rb @@ -353,7 +353,10 @@ class SiteFeedAnnc end pipeline_to_get_count = pipeline.clone - pipeline_to_get_count << {"$count" => "count"} + pipeline_to_get_count << {"$group" => { + _id: nil, + count: {"$sum" => 1} + }} count_result = SiteFeedAnncDetail.collection.aggregate(pipeline_to_get_count).first feeds_count = count_result ? count_result["count"] : 0