mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Use named scope for finding line_items in a set of orders
This commit is contained in:
@@ -36,6 +36,10 @@ Spree::LineItem.class_eval do
|
||||
end
|
||||
}
|
||||
|
||||
scope :in_orders, lambda { |orders|
|
||||
where(order_id: orders)
|
||||
}
|
||||
|
||||
# Find line items that are from order sorted by variant name and unit value
|
||||
scope :sorted_by_name_and_unit_value, -> {
|
||||
joins(variant: :product).
|
||||
|
||||
@@ -12,9 +12,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def list(line_item_includes = nil)
|
||||
line_items = @order_permissions.
|
||||
visible_line_items.
|
||||
merge(Spree::LineItem.where(order_id: orders.result))
|
||||
line_items = @order_permissions.visible_line_items.in_orders(orders.result)
|
||||
|
||||
if @params[:supplier_id_in].present?
|
||||
line_items = line_items.supplied_by_any(@params[:supplier_id_in])
|
||||
|
||||
Reference in New Issue
Block a user