remove subquery for optimization

This commit is contained in:
Ahmed Ejaz
2025-03-05 03:28:44 +05:00
parent f132d99df4
commit adbdc64c13

View File

@@ -24,8 +24,7 @@ module Permissions
# Any orders that the user can edit
def editable_orders
orders = if @user.can_manage_line_items_in_orders_only?
Spree::Order.joins(:distributor).where(
id: produced_orders.select(:id),
produced_orders.joins(:distributor).where(
distributor: { enable_producers_to_edit_orders: true }
)
else