Skip to content

Commit

Permalink
Fix a few more rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
luisramos0 committed Jun 18, 2019
1 parent 178924a commit b025df1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ def destroy_with_delete_from_order_cycles
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
Expand All @@ -216,7 +218,7 @@ def update_units
end

def touch_distributors
Enterprise.distributing_products(self.id).each(&:touch)
Enterprise.distributing_products(id).each(&:touch)
end

def add_primary_taxon_to_taxons
Expand Down
9 changes: 6 additions & 3 deletions lib/open_food_network/order_cycle_permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def visible_enterprises
# 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
Expand Down Expand Up @@ -248,8 +249,10 @@ def order_cycle_exchange_ids_distributing_my_variants
# 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
Expand Down
3 changes: 2 additions & 1 deletion lib/open_food_network/products_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def self.distributor_changed(enterprise)
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
Expand Down

0 comments on commit b025df1

Please sign in to comment.