diff --git a/app/models/schedule.rb b/app/models/schedule.rb index 3b94059c20..9450b160b5 100644 --- a/app/models/schedule.rb +++ b/app/models/schedule.rb @@ -3,7 +3,7 @@ class Schedule < ActiveRecord::Base has_many :order_cycle_schedules, dependent: :destroy has_many :order_cycles, through: :order_cycle_schedules - has_many :coordinators, -> { uniq }, through: :order_cycles + has_many :coordinators, -> { distinct }, through: :order_cycles scope :with_coordinator, lambda { |enterprise| joins(:order_cycles).where('coordinator_id = ?', enterprise.id).select('DISTINCT schedules.*') } diff --git a/lib/open_food_network/sales_tax_report.rb b/lib/open_food_network/sales_tax_report.rb index 83bfadd8b6..af50c3cc85 100644 --- a/lib/open_food_network/sales_tax_report.rb +++ b/lib/open_food_network/sales_tax_report.rb @@ -70,7 +70,7 @@ module OpenFoodNetwork def relevant_rates return @relevant_rates unless @relevant_rates.nil? - @relevant_rates = Spree::TaxRate.uniq + @relevant_rates = Spree::TaxRate.distinct end def totals_of(line_items) diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 33ac11f020..a8255b96bc 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -41,7 +41,7 @@ namespace :ofn do # For each variant in the exchange products = Spree::Product.joins(:variants_including_master).where('spree_variants.id IN (?)', exchange.variants).pluck(:id).uniq - producers = Enterprise.joins(:supplied_products).where("spree_products.id IN (?)", products).uniq + producers = Enterprise.joins(:supplied_products).where("spree_products.id IN (?)", products).distinct producers.each do |producer| next if producer == exchange.receiver