mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move relation includes out of query object
This query object is meant to be reusable but those includes are context-specific and will likely not be needed when reusing the query elsewhere. If we keep them there, chances are next dev might not notice it and will introduce a performance regression.
This commit is contained in:
@@ -65,7 +65,8 @@ module Admin
|
||||
|
||||
def collection
|
||||
if json_request? && params[:enterprise_id].present?
|
||||
CustomersWithBalance.new(managed_enterprise_id).query
|
||||
CustomersWithBalance.new(managed_enterprise_id).query.
|
||||
includes(:bill_address, :ship_address, user: :credit_cards)
|
||||
else
|
||||
Customer.where('1=0')
|
||||
end
|
||||
|
||||
@@ -7,7 +7,6 @@ class CustomersWithBalance
|
||||
|
||||
def query
|
||||
Customer.of(enterprise_id).
|
||||
includes(:bill_address, :ship_address, user: :credit_cards).
|
||||
joins(left_join_non_cart_orders).
|
||||
group("customers.id").
|
||||
select("customers.*").
|
||||
|
||||
Reference in New Issue
Block a user