Skip to content

Commit 65b99bf

Browse files
perf(solidus_admin): Remove distinct from product scopes
The distinct isn't necessary, because the result will be put into an IN filter and there is no reason to filter out possible duplicates. It slows only the query.
1 parent 8570839 commit 65b99bf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

admin/app/controllers/solidus_admin/products_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class ProductsController < SolidusAdmin::BaseController
88
search_scope(:deleted) { _1.with_discarded.discarded }
99
search_scope(:discontinued) { _1.where(discontinue_on: ...Time.current) }
1010
search_scope(:available) { _1.available }
11-
search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
12-
search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
11+
search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.select(:product_id)) }
12+
search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.select(:product_id)) }
1313

1414
def index
1515
products = apply_search_to(

0 commit comments

Comments
 (0)