Extract method from cache key generation

This commit is contained in:
Pau Perez
2019-03-06 10:49:56 +01:00
parent bbfd35c861
commit 2b58aab197

View File

@@ -2,12 +2,15 @@ require 'open_food_network/products_renderer'
RefreshProductsCacheJob = Struct.new(:distributor_id, :order_cycle_id) do
def perform
Rails.cache.write "products-json-#{distributor_id}-#{order_cycle_id}", products_json
Rails.cache.write(key, products_json)
end
private
def key
"products-json-#{distributor_id}-#{order_cycle_id}"
end
def products_json
distributor = Enterprise.find distributor_id
order_cycle = OrderCycle.find order_cycle_id