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.

Reduce N+1 queries in Admin Panel

Damian Legawiecdfc028e5eea2
diff --git a/backend/app/controllers/spree/admin/products_controller.rb b/backend/app/controllers/spree/admin/products_controller.rb
index 3449493229..d4bbe485c7 100644
--- a/backend/app/controllers/spree/admin/products_controller.rb
+++ b/backend/app/controllers/spree/admin/products_controller.rb
@@ -151,7 +151,12 @@ module Spree
end
def product_includes
- [{ variants: [:images], master: [:images, :default_price] }]
+ {
+ variant_images: [],
+ tax_category: [],
+ master: [],
+ variants: [:prices]
+ }
end
def clone_object_url(resource)
diff --git a/backend/app/controllers/spree/admin/store_credits_controller.rb b/backend/app/controllers/spree/admin/store_credits_controller.rb
index f6291237ce..6041ef1417 100644
--- a/backend/app/controllers/spree/admin/store_credits_controller.rb
+++ b/backend/app/controllers/spree/admin/store_credits_controller.rb
@@ -9,7 +9,7 @@ module Spree
before_action :ensure_unused_store_credit, only: [:update]
def index
- @store_credits = @user.store_credits.for_store(current_store).includes(:credit_type, :category).reverse_order
+ @store_credits = @user.store_credits.for_store(current_store).includes(:category).reverse_order
end
def create