Fix a few more rubocop issues

This commit is contained in:
luisramos0
2019-05-29 10:48:51 +01:00
parent 178924af5d
commit b025df1798
3 changed files with 12 additions and 6 deletions

View File

@@ -189,7 +189,9 @@ Spree::Product.class_eval do
OpenFoodNetwork::ProductsCache.product_deleted(self) do
touch_distributors
ExchangeVariant.where('exchange_variants.variant_id IN (?)', variants_including_master.with_deleted.select(:id)).destroy_all
ExchangeVariant.
where('exchange_variants.variant_id IN (?)', variants_including_master.with_deleted.
select(:id)).destroy_all
destroy_without_delete_from_order_cycles
end
@@ -216,7 +218,7 @@ Spree::Product.class_eval do
end
def touch_distributors
Enterprise.distributing_products(self.id).each(&:touch)
Enterprise.distributing_products(id).each(&:touch)
end
def add_primary_taxon_to_taxons

View File

@@ -55,7 +55,8 @@ module OpenFoodNetwork
# TODO: Remove this when all P-OC are sorted out
# Any hubs that currently have outgoing exchanges distributing variants of producers I manage
variants = Spree::Variant.joins(:product).where('spree_products.supplier_id IN (?)', managed_enterprises.is_primary_producer)
active_exchanges = @order_cycle.exchanges.outgoing.with_any_variant(variants.select("spree_variants.id"))
active_exchanges = @order_cycle.
exchanges.outgoing.with_any_variant(variants.select("spree_variants.id"))
hubs_active = active_exchanges.map(&:receiver_id)
# TODO: Remove this when all P-OC are sorted out
@@ -248,8 +249,10 @@ module OpenFoodNetwork
# active_exchanges is for backward compatability, before we restricted variants in each
# outgoing exchange to those where the producer had granted P-OC to the distributor
# For any of my managed producers, any outgoing exchanges with their variants
variants = Spree::Variant.joins(:product).where('spree_products.supplier_id IN (?)', producers)
active_exchanges = @order_cycle.exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")).pluck :id
variants = Spree::Variant.
joins(:product).where('spree_products.supplier_id IN (?)', producers)
active_exchanges = @order_cycle.
exchanges.outgoing.with_any_variant(variants.select("spree_variants.id")).pluck :id
permitted_exchanges | active_exchanges
end

View File

@@ -94,7 +94,8 @@ module OpenFoodNetwork
end
def self.inventory_item_changed(inventory_item)
exchanges_featuring_variants(inventory_item.variant.id, distributor: inventory_item.enterprise).each do |exchange|
exchanges_featuring_variants(inventory_item.variant.id,
distributor: inventory_item.enterprise).each do |exchange|
refresh_cache exchange.receiver, exchange.order_cycle
end
end