mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Perform refresh of products cache when distributor fee is changed
This commit is contained in:
@@ -51,6 +51,7 @@ module OpenFoodNetwork
|
||||
|
||||
def self.enterprise_fee_changed(enterprise_fee)
|
||||
refresh_coordinator_fee enterprise_fee
|
||||
refresh_distributor_fee enterprise_fee
|
||||
end
|
||||
|
||||
|
||||
@@ -82,6 +83,19 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_distributor_fee(enterprise_fee)
|
||||
enterprise_fee.exchange_fees.
|
||||
joins(:exchange => :order_cycle).
|
||||
merge(Exchange.outgoing).
|
||||
merge(OrderCycle.dated).
|
||||
merge(OrderCycle.not_closed).
|
||||
each do |exf|
|
||||
|
||||
refresh_cache exf.exchange.receiver, exf.exchange.order_cycle
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_cache(distributor, order_cycle)
|
||||
Delayed::Job.enqueue RefreshProductsCacheJob.new distributor.id, order_cycle.id
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user