From db1dfb1046f7f86e732b67ad185f9b80dcc2d970 Mon Sep 17 00:00:00 2001 From: JD Guzman Date: Fri, 27 Nov 2020 11:45:28 +0000 Subject: [PATCH 1/2] use a count query instead of counting array --- lib/active_admin/mongoid/helpers/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/mongoid/helpers/collection.rb b/lib/active_admin/mongoid/helpers/collection.rb index 10e5fd8..483bafa 100644 --- a/lib/active_admin/mongoid/helpers/collection.rb +++ b/lib/active_admin/mongoid/helpers/collection.rb @@ -8,7 +8,7 @@ module Collection def collection_size(collection = nil) collection ||= self.collection if collection.is_a?(::Mongoid::Criteria) - collection.entries.count + collection.count else original_collection_size(collection) end From 1feb302f5bbb0b7d00630a238a229c1c5021e627 Mon Sep 17 00:00:00 2001 From: JD Guzman Date: Fri, 27 Nov 2020 12:29:28 +0000 Subject: [PATCH 2/2] handle pagination counts issue --- lib/active_admin/mongoid/helpers/collection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_admin/mongoid/helpers/collection.rb b/lib/active_admin/mongoid/helpers/collection.rb index 483bafa..acce98b 100644 --- a/lib/active_admin/mongoid/helpers/collection.rb +++ b/lib/active_admin/mongoid/helpers/collection.rb @@ -8,7 +8,7 @@ module Collection def collection_size(collection = nil) collection ||= self.collection if collection.is_a?(::Mongoid::Criteria) - collection.count + collection.options[:limit].present? ? collection.entries.count : collection.count else original_collection_size(collection) end