From 821eaaaebe4244fbe7f5e661cea7429d06c56048 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Wed, 28 Feb 2024 13:50:37 +0100 Subject: [PATCH] world map caching properly this time? --- app/controllers/v0/devices_controller.rb | 2 -- app/views/v0/devices/_world_map_list.jbuilder | 1 + app/views/v0/devices/fresh_world_map.jbuilder | 1 + app/views/v0/devices/world_map.jbuilder | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 app/views/v0/devices/_world_map_list.jbuilder create mode 100644 app/views/v0/devices/fresh_world_map.jbuilder diff --git a/app/controllers/v0/devices_controller.rb b/app/controllers/v0/devices_controller.rb index a7a67ee1..22d67e9a 100644 --- a/app/controllers/v0/devices_controller.rb +++ b/app/controllers/v0/devices_controller.rb @@ -75,8 +75,6 @@ def destroy # debug method, must be refactored def fresh_world_map - @no_cache = true - render :world_map end def world_map diff --git a/app/views/v0/devices/_world_map_list.jbuilder b/app/views/v0/devices/_world_map_list.jbuilder new file mode 100644 index 00000000..28c642db --- /dev/null +++ b/app/views/v0/devices/_world_map_list.jbuilder @@ -0,0 +1 @@ +json.array! Device.for_world_map, partial: 'device', as: :device, local_assigns: { with_data: false, with_postprocessing: false, slim_owner: true, never_authorized: true } \ No newline at end of file diff --git a/app/views/v0/devices/fresh_world_map.jbuilder b/app/views/v0/devices/fresh_world_map.jbuilder new file mode 100644 index 00000000..021cc4c5 --- /dev/null +++ b/app/views/v0/devices/fresh_world_map.jbuilder @@ -0,0 +1 @@ +json.partial! 'devices/world_map_list' \ No newline at end of file diff --git a/app/views/v0/devices/world_map.jbuilder b/app/views/v0/devices/world_map.jbuilder index 4c94ea3f..ac9a2abd 100644 --- a/app/views/v0/devices/world_map.jbuilder +++ b/app/views/v0/devices/world_map.jbuilder @@ -1,3 +1,3 @@ -json.cache_if! !@no_cache, ["world_map"], expires_in: 1.minute do - json.array! Device.for_world_map, partial: 'device', as: :device, local_assigns: { with_data: false, with_postprocessing: false, slim_owner: true, never_authorized: true } +json.cache! ["world_map"], expires_in: 1.minute do + json.partial! 'devices/world_map_list' end \ No newline at end of file