Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

It does not make sens to eagerly load for singular resource

Damian Legawiec481bafc319b8
diff --git a/api/app/controllers/spree/api/v2/resource_controller.rb b/api/app/controllers/spree/api/v2/resource_controller.rb
index 3276f54dbc..f93969b5fc 100644
--- a/api/app/controllers/spree/api/v2/resource_controller.rb
+++ b/api/app/controllers/spree/api/v2/resource_controller.rb
@@ -29,7 +29,7 @@ module Spree
def scope(skip_cancancan: false)
base_scope = model_class.for_store(current_store)
base_scope = base_scope.accessible_by(current_ability, :show) unless skip_cancancan
- base_scope = base_scope.includes(scope_includes) if scope_includes.any?
+ base_scope = base_scope.includes(scope_includes) if scope_includes.any? && action_name == 'index'
base_scope
end
diff --git a/core/app/finders/spree/orders/find_current.rb b/core/app/finders/spree/orders/find_current.rb
index 06c627d3d1..376723f977 100644
--- a/core/app/finders/spree/orders/find_current.rb
+++ b/core/app/finders/spree/orders/find_current.rb
@@ -15,19 +15,7 @@ module Spree
private
def incomplete_orders
- Spree::Order.incomplete.not_canceled.includes(scope_includes)
- end
-
- def scope_includes
- {
- line_items: [
- variant: [
- :images,
- option_values: :option_type,
- product: :product_properties,
- ]
- ]
- }
+ Spree::Order.incomplete.not_canceled
end
end
end