From 2292cbaae4fe9d7da814744a39554b6bc024b5ee Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 30 Apr 2020 10:05:46 +0200 Subject: [PATCH] Extract timed enterprise AMS fragment caching options to service --- app/services/cache_service.rb | 14 ++++++++++++++ app/views/enterprises/shop.html.haml | 2 +- app/views/shops/index.html.haml | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/services/cache_service.rb b/app/services/cache_service.rb index 79d81068eb..682911457e 100644 --- a/app/services/cache_service.rb +++ b/app/services/cache_service.rb @@ -36,5 +36,19 @@ class CacheService def self.ams_all_properties_key "inject-all-properties-#{CacheService.latest_timestamp_by_class(Spree::Property)}" end + + def self.ams_shops + [ + "shops/index/inject_enterprises", + { expires_in: SHOPS_EXPIRY } + ] + end + + def self.ams_shop(enterprise) + [ + "enterprises/shop/inject_enterprise_shopfront-#{enterprise.id}", + { expires_in: SHOPS_EXPIRY } + ] + end end end diff --git a/app/views/enterprises/shop.html.haml b/app/views/enterprises/shop.html.haml index b6bf91ed06..1bc7bba978 100644 --- a/app/views/enterprises/shop.html.haml +++ b/app/views/enterprises/shop.html.haml @@ -6,7 +6,7 @@ = current_distributor.logo.url - content_for :injection_data do - - cache "enterprises/shop/inject_enterprise_shopfront-#{@enterprise.id}", expires_in: CacheService::SHOPS_EXPIRY do + - cache(*CacheService::FragmentCaching.ams_shop(@enterprise)) do = inject_enterprise_shopfront(@enterprise) %shop.darkswarm diff --git a/app/views/shops/index.html.haml b/app/views/shops/index.html.haml index 0bf7709674..032096ebb9 100644 --- a/app/views/shops/index.html.haml +++ b/app/views/shops/index.html.haml @@ -2,7 +2,7 @@ = t :shops_title - content_for :injection_data do - - cache "shops/index/inject_enterprises", expires_in: CacheService::SHOPS_EXPIRY do + - cache(*CacheService::FragmentCaching.ams_shops) do = inject_enterprises(@enterprises) #panes