From bc9e0d46aff40bb9ec6f18346c86bb45d500bac6 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 14 May 2018 12:01:44 +1000 Subject: [PATCH] PERF: use cached reports for dashboard if available --- app/controllers/admin/dashboard_next_controller.rb | 2 +- app/jobs/scheduled/dashboard_stats.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/dashboard_next_controller.rb b/app/controllers/admin/dashboard_next_controller.rb index 7e6260cbf8f..908a4206d45 100644 --- a/app/controllers/admin/dashboard_next_controller.rb +++ b/app/controllers/admin/dashboard_next_controller.rb @@ -2,7 +2,7 @@ require 'disk_space' class Admin::DashboardNextController < Admin::AdminController def index - dashboard_data = AdminDashboardNextData.fetch_stats + dashboard_data = AdminDashboardNextData.fetch_cached_stats dashboard_data[:disk_space] = DiskSpace.cached_stats render json: dashboard_data end diff --git a/app/jobs/scheduled/dashboard_stats.rb b/app/jobs/scheduled/dashboard_stats.rb index 9556bd7ea1a..7e5fe8c4233 100644 --- a/app/jobs/scheduled/dashboard_stats.rb +++ b/app/jobs/scheduled/dashboard_stats.rb @@ -14,7 +14,9 @@ module Jobs GroupMessage.create(Group[:admins].name, :dashboard_problems, limit_once_per: 7.days.to_i) end + # TODO: decide if we want to keep caching this every 30 minutes AdminDashboardData.refresh_stats + AdminDashboardNextData.refresh_stats end end end