mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove distinct from enterprise.ready_for_checkout scope
Adapt use of enterprise scope not_ready_for_checkout to rails 4 by adding enterprises table alias to selected field id
This commit is contained in:
@@ -52,7 +52,7 @@ Spree::Admin::BaseController.class_eval do
|
||||
def active_distributors_not_ready_for_checkout
|
||||
ocs = OrderCycle.managed_by(spree_current_user).active
|
||||
distributors = ocs.map(&:distributors).flatten.uniq
|
||||
Enterprise.where('id IN (?)', distributors).not_ready_for_checkout
|
||||
Enterprise.where('enterprises.id IN (?)', distributors).not_ready_for_checkout
|
||||
end
|
||||
|
||||
def active_distributors_not_ready_for_checkout_message(distributors)
|
||||
|
||||
@@ -111,14 +111,14 @@ class Enterprise < ActiveRecord::Base
|
||||
joins(:shipping_methods).
|
||||
joins(:payment_methods).
|
||||
merge(Spree::PaymentMethod.available).
|
||||
select('DISTINCT enterprises.id')
|
||||
select('enterprises.id')
|
||||
}
|
||||
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
|
||||
if ready_enterprises.present?
|
||||
where("id NOT IN (?)", ready_enterprises)
|
||||
where("enterprises.id NOT IN (?)", ready_enterprises)
|
||||
else
|
||||
where("TRUE")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user