mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix subquery errors triggered by #warn_invalid_order_cycles
This commit is contained in:
@@ -97,7 +97,7 @@ module Spree
|
||||
def active_distributors_not_ready_for_checkout
|
||||
ocs = OrderCycle.managed_by(spree_current_user).active
|
||||
distributors = ocs.includes(:distributors).map(&:distributors).flatten.uniq
|
||||
Enterprise.where('enterprises.id IN (?)', distributors).not_ready_for_checkout
|
||||
Enterprise.where(id: distributors.map(&:id)).not_ready_for_checkout
|
||||
end
|
||||
|
||||
def active_distributors_not_ready_for_checkout_message(distributors)
|
||||
|
||||
@@ -115,7 +115,7 @@ class Enterprise < ActiveRecord::Base
|
||||
scope :not_ready_for_checkout, lambda {
|
||||
# When ready_for_checkout is empty, return all rows when there are no enterprises ready for
|
||||
# checkout.
|
||||
ready_enterprises = Enterprise.ready_for_checkout.select('enterprises.id')
|
||||
ready_enterprises = Enterprise.ready_for_checkout.pluck(:id)
|
||||
if ready_enterprises.present?
|
||||
where("enterprises.id NOT IN (?)", ready_enterprises)
|
||||
else
|
||||
|
||||
@@ -63,7 +63,7 @@ class OrderCycle < ActiveRecord::Base
|
||||
if user.has_spree_role?('admin')
|
||||
scoped
|
||||
else
|
||||
where('coordinator_id IN (?)', user.enterprises.map(&:id))
|
||||
where(coordinator_id: user.enterprises)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user