mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Merge pull request #3593 from tgxworld/cache_results_on_about_page
Cache results on about page
This commit is contained in:
commit
e3d6c476f5
12 changed files with 121 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
|||
require_dependency 'mem_info'
|
||||
|
||||
class AdminDashboardData
|
||||
include StatsCacheable
|
||||
|
||||
GLOBAL_REPORTS ||= [
|
||||
'visits',
|
||||
|
@ -57,13 +58,7 @@ class AdminDashboardData
|
|||
|
||||
|
||||
def self.fetch_stats
|
||||
AdminDashboardData.new
|
||||
end
|
||||
|
||||
def self.fetch_cached_stats
|
||||
# The DashboardStats job is responsible for generating and caching this.
|
||||
stats = $redis.get(stats_cache_key)
|
||||
stats ? JSON.parse(stats) : nil
|
||||
AdminDashboardData.new.as_json
|
||||
end
|
||||
|
||||
def self.stats_cache_key
|
||||
|
@ -97,11 +92,6 @@ class AdminDashboardData
|
|||
source.map { |type| Report.find(type).as_json }
|
||||
end
|
||||
|
||||
# Could be configurable, multisite need to support it.
|
||||
def self.recalculate_interval
|
||||
30 # minutes
|
||||
end
|
||||
|
||||
def rails_env_check
|
||||
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env.production?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue