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:
Pau Perez
2020-11-26 10:16:19 +01:00
parent 46d997406a
commit 2e9bae0ea5
2 changed files with 2 additions and 2 deletions

View File

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

View File

@@ -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.*").