mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Don't fetch rows by ids of DISTINCT records
There's no point on fetching the same records again by the resulting ids of the previous query (nasty way of removing duplicates), when that query has a DISTINCT.
This commit is contained in:
@@ -85,14 +85,12 @@ module Api
|
||||
def distributed_properties
|
||||
if active
|
||||
product_properties = Spree::Property.currently_sold_by(enterprise)
|
||||
producer_property_ids = ProducerProperty.currently_sold_by(enterprise).pluck(:property_id)
|
||||
producer_properties = ProducerProperty.currently_sold_by(enterprise)
|
||||
else
|
||||
product_properties = Spree::Property.ever_sold_by(enterprise)
|
||||
producer_property_ids = ProducerProperty.ever_sold_by(enterprise).pluck(:property_id)
|
||||
producer_properties = ProducerProperty.ever_sold_by(enterprise)
|
||||
end
|
||||
|
||||
producer_properties = Spree::Property.where(id: producer_property_ids)
|
||||
|
||||
(product_properties + producer_properties).uniq do |property_object|
|
||||
property_object.property.presentation
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user