mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
involving... order cycle scopes return distinct OCs
This commit is contained in:
@@ -70,7 +70,8 @@ class OrderCycle < ActiveRecord::Base
|
||||
# Order cycles where I managed an enterprise at either end of an outgoing exchange
|
||||
# ie. coordinator or distibutor
|
||||
joins(:exchanges).merge(Exchange.outgoing).
|
||||
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises)
|
||||
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises).
|
||||
select('DISTINCT order_cycles.*')
|
||||
}
|
||||
|
||||
scope :involving_managed_producers_of, lambda { |user|
|
||||
@@ -79,7 +80,8 @@ class OrderCycle < ActiveRecord::Base
|
||||
# Order cycles where I managed an enterprise at either end of an incoming exchange
|
||||
# ie. coordinator or producer
|
||||
joins(:exchanges).merge(Exchange.incoming).
|
||||
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises)
|
||||
where('exchanges.receiver_id IN (?) OR exchanges.sender_id IN (?)', enterprises, enterprises).
|
||||
select('DISTINCT order_cycles.*')
|
||||
}
|
||||
|
||||
def self.first_opening_for(distributor)
|
||||
|
||||
Reference in New Issue
Block a user