mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-17 04:34:24 +00:00
Fix integrity checker error message, add task to warm products cache
This commit is contained in:
@@ -3,7 +3,7 @@ require 'open_food_network/products_renderer'
|
||||
ProductsCacheIntegrityCheckerJob = Struct.new(:distributor_id, :order_cycle_id) do
|
||||
def perform
|
||||
if diff.any?
|
||||
Bugsnag.notify RuntimeError.new("Products JSON differs from cached version for distributor: #{@distributor_id}, order cycle: #{@order_cycle_id}"), diff: diff.to_s(:text)
|
||||
Bugsnag.notify RuntimeError.new("Products JSON differs from cached version for distributor: #{distributor_id}, order cycle: #{order_cycle_id}"), diff: diff.to_s(:text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,16 +1,29 @@
|
||||
namespace :openfoodnetwork do
|
||||
namespace :cache do
|
||||
desc 'check the integrity of the products cache'
|
||||
task :check_products_cache_integrity => :environment do
|
||||
exchanges = Exchange.
|
||||
outgoing.
|
||||
joins(:order_cycle).
|
||||
merge(OrderCycle.dated).
|
||||
merge(OrderCycle.not_closed)
|
||||
|
||||
exchanges.each do |exchange|
|
||||
Delayed::Job.enqueue ProductsCacheIntegrityCheckerJob.new(exchange.receiver, exchange.order_cycle), priority: 20
|
||||
task :check_products_integrity => :environment do
|
||||
active_exchanges.each do |exchange|
|
||||
Delayed::Job.enqueue ProductsCacheIntegrityCheckerJob.new(exchange.receiver_id, exchange.order_cycle_id), priority: 20
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
desc 'warm the products cache'
|
||||
task :warm_products => :environment do
|
||||
active_exchanges.each do |exchange|
|
||||
Delayed::Job.enqueue RefreshProductsCacheJob.new(exchange.receiver_id, exchange.order_cycle_id), priority: 10
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def active_exchanges
|
||||
Exchange.
|
||||
outgoing.
|
||||
joins(:order_cycle).
|
||||
merge(OrderCycle.dated).
|
||||
merge(OrderCycle.not_closed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user