8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f82cffc commit 116e621Copy full SHA for 116e621
lib/active_admin/helpers/collection.rb
@@ -4,13 +4,13 @@ module Helpers
4
module Collection
5
# 1. removes `select` and `order` to prevent invalid SQL
6
# 2. correctly handles the Hash returned when `group by` is used
7
+ # 3. Avoids duplicative COUNT/subquery_for_count queries
8
def collection_size(c = collection)
- return c.count if c.is_a?(Array)
9
- return c.length if c.limit_value
+ # 'length' avoids count query on unloaded collection with a limit_value
10
+ return c.length if c.is_a?(Array) || c.limit_value.present?
11
12
c = c.except :select, :order
-
13
- c.group_values.present? ? c.count.count : c.count
+ c.group_values.present? ? c.size.size : c.size
14
end
15
16
def collection_is_empty?(c = collection)
0 commit comments