Skip to content

Commit

Permalink
avoid count query
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoyoussef committed Nov 14, 2024
1 parent a334e4f commit 5b21720
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/avo/associations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def select_options(query)
query.all.limit(Avo.configuration.associations_query_limit).map do |record|
[@attachment_resource.new(record: record).record_title, record.to_param]
end.tap do |options|
options << t("avo.more_records_available") if query.all.count > Avo.configuration.associations_query_limit
options << t("avo.more_records_available") if options.count == Avo.configuration.associations_query_limit
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/fields/belongs_to_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def values_for_type(model = nil)
query.all.limit(Avo.configuration.associations_query_limit).map do |record|
[resource.new(record: record).record_title, record.to_param]
end.tap do |options|
options << t("avo.more_records_available") if query.all.count > Avo.configuration.associations_query_limit
options << t("avo.more_records_available") if options.count == Avo.configuration.associations_query_limit
end
end

Expand Down

0 comments on commit 5b21720

Please sign in to comment.