fix error for mongo version smaller than 3.4

This commit is contained in:
chiu 2024-10-15 05:18:48 +00:00
parent 16963a9cb2
commit 93ff42af46
1 changed files with 4 additions and 1 deletions

View File

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