mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move select out of scope visible_for because it is breaking exchange_product queries and it's just not needed there. The only other use of this product's scope visible_for is the enterprise serializer so we add the select to it.
This commit is contained in:
@@ -63,8 +63,7 @@ Spree::Product.class_eval do
|
||||
scope :visible_for, lambda { |enterprise|
|
||||
joins('LEFT OUTER JOIN spree_variants AS o_spree_variants ON (o_spree_variants.product_id = spree_products.id)').
|
||||
joins('LEFT OUTER JOIN inventory_items AS o_inventory_items ON (o_spree_variants.id = o_inventory_items.variant_id)').
|
||||
where('o_inventory_items.enterprise_id = (?) AND visible = (?)', enterprise, true).
|
||||
select('DISTINCT spree_products.*')
|
||||
where('o_inventory_items.enterprise_id = (?) AND visible = (?)', enterprise, true)
|
||||
}
|
||||
|
||||
# -- Scopes
|
||||
|
||||
@@ -30,7 +30,9 @@ class Api::Admin::ForOrderCycle::EnterpriseSerializer < ActiveModel::Serializer
|
||||
def products_scope
|
||||
products_relation = object.supplied_products
|
||||
if order_cycle.prefers_product_selection_from_coordinator_inventory_only?
|
||||
products_relation = products_relation.visible_for(order_cycle.coordinator)
|
||||
products_relation = products_relation.
|
||||
visible_for(order_cycle.coordinator).
|
||||
select('DISTINCT spree_products.*')
|
||||
end
|
||||
products_relation.order(:name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user