mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: removes old dashboard (#7295)
This commit is contained in:
@ -3,36 +3,29 @@ require_dependency 'mem_info'
|
||||
class AdminDashboardData
|
||||
include StatsCacheable
|
||||
|
||||
GLOBAL_REPORTS ||= [
|
||||
'visits',
|
||||
'signups',
|
||||
'profile_views',
|
||||
'topics',
|
||||
'posts',
|
||||
'time_to_first_response',
|
||||
'topics_with_no_response',
|
||||
'likes',
|
||||
'flags',
|
||||
'bookmarks',
|
||||
'emails',
|
||||
]
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
PAGE_VIEW_REPORTS ||= ['page_view_total_reqs'] + ApplicationRequest.req_types.keys.select { |r| r =~ /^page_view_/ && r !~ /mobile/ }.map { |r| r + "_reqs" }
|
||||
def self.fetch_stats
|
||||
new.as_json
|
||||
end
|
||||
|
||||
PRIVATE_MESSAGE_REPORTS ||= [
|
||||
'user_to_user_private_messages',
|
||||
'user_to_user_private_messages_with_replies',
|
||||
'system_private_messages',
|
||||
'notify_moderators_private_messages',
|
||||
'notify_user_private_messages',
|
||||
'moderator_warning_private_messages',
|
||||
]
|
||||
def get_json
|
||||
{}
|
||||
end
|
||||
|
||||
HTTP_REPORTS ||= ApplicationRequest.req_types.keys.select { |r| r =~ /^http_/ }.map { |r| r + "_reqs" }.sort
|
||||
def as_json(_options = nil)
|
||||
@json ||= get_json
|
||||
end
|
||||
|
||||
USER_REPORTS ||= ['users_by_trust_level']
|
||||
def self.reports(source)
|
||||
source.map { |type| Report.find(type).as_json }
|
||||
end
|
||||
|
||||
MOBILE_REPORTS ||= ['mobile_visits'] + ApplicationRequest.req_types.keys.select { |r| r =~ /mobile/ }.map { |r| r + "_reqs" }
|
||||
def self.stats_cache_key
|
||||
"dashboard-data-#{Report::SCHEMA_VERSION}"
|
||||
end
|
||||
|
||||
def self.add_problem_check(*syms, &blk)
|
||||
@problem_syms.push(*syms) if syms
|
||||
@ -40,10 +33,6 @@ class AdminDashboardData
|
||||
end
|
||||
class << self; attr_reader :problem_syms, :problem_blocks, :problem_messages; end
|
||||
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
def problems
|
||||
problems = []
|
||||
AdminDashboardData.problem_syms.each do |sym|
|
||||
@ -67,7 +56,7 @@ class AdminDashboardData
|
||||
end
|
||||
|
||||
def self.problems_started_key
|
||||
"dash-problems-started-at"
|
||||
'dash-problems-started-at'
|
||||
end
|
||||
|
||||
def self.set_problems_started
|
||||
@ -110,14 +99,6 @@ class AdminDashboardData
|
||||
end
|
||||
reset_problem_checks
|
||||
|
||||
def self.fetch_stats
|
||||
AdminDashboardData.new.as_json
|
||||
end
|
||||
|
||||
def self.stats_cache_key
|
||||
'dash-stats'
|
||||
end
|
||||
|
||||
def self.fetch_problems(opts = {})
|
||||
AdminDashboardData.new(opts).problems
|
||||
end
|
||||
@ -142,29 +123,6 @@ class AdminDashboardData
|
||||
"admin-problem:#{i18n_key}"
|
||||
end
|
||||
|
||||
def as_json(_options = nil)
|
||||
@json ||= {
|
||||
global_reports: AdminDashboardData.reports(GLOBAL_REPORTS),
|
||||
page_view_reports: AdminDashboardData.reports(PAGE_VIEW_REPORTS),
|
||||
private_message_reports: AdminDashboardData.reports(PRIVATE_MESSAGE_REPORTS),
|
||||
http_reports: AdminDashboardData.reports(HTTP_REPORTS),
|
||||
user_reports: AdminDashboardData.reports(USER_REPORTS),
|
||||
mobile_reports: AdminDashboardData.reports(MOBILE_REPORTS),
|
||||
admins: User.admins.count,
|
||||
moderators: User.moderators.count,
|
||||
suspended: User.suspended.count,
|
||||
silenced: User.silenced.count,
|
||||
top_referrers: IncomingLinksReport.find('top_referrers').as_json,
|
||||
top_traffic_sources: IncomingLinksReport.find('top_traffic_sources').as_json,
|
||||
top_referred_topics: IncomingLinksReport.find('top_referred_topics').as_json,
|
||||
updated_at: Time.zone.now.as_json
|
||||
}
|
||||
end
|
||||
|
||||
def self.reports(source)
|
||||
source.map { |type| Report.find(type).as_json }
|
||||
end
|
||||
|
||||
def rails_env_check
|
||||
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env.production?
|
||||
end
|
||||
@ -260,7 +218,7 @@ class AdminDashboardData
|
||||
|
||||
def missing_mailgun_api_key
|
||||
return unless SiteSetting.reply_by_email_enabled
|
||||
return unless ActionMailer::Base.smtp_settings[:address]["smtp.mailgun.org"]
|
||||
return unless ActionMailer::Base.smtp_settings[:address]['smtp.mailgun.org']
|
||||
return unless SiteSetting.mailgun_api_key.blank?
|
||||
I18n.t('dashboard.missing_mailgun_api_key')
|
||||
end
|
||||
@ -274,14 +232,14 @@ class AdminDashboardData
|
||||
old_themes = RemoteTheme.out_of_date_themes
|
||||
return unless old_themes.present?
|
||||
|
||||
themes_html_format(old_themes, "dashboard.out_of_date_themes")
|
||||
themes_html_format(old_themes, 'dashboard.out_of_date_themes')
|
||||
end
|
||||
|
||||
def unreachable_themes
|
||||
themes = RemoteTheme.unreachable_themes
|
||||
return unless themes.present?
|
||||
|
||||
themes_html_format(themes, "dashboard.unreachable_themes")
|
||||
themes_html_format(themes, 'dashboard.unreachable_themes')
|
||||
end
|
||||
|
||||
private
|
||||
@ -291,8 +249,6 @@ class AdminDashboardData
|
||||
"<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>"
|
||||
end.join("\n")
|
||||
|
||||
message = I18n.t(i18n_key)
|
||||
message += "<ul>#{html}</ul>"
|
||||
message
|
||||
"#{I18n.t(i18n_key)}<ul>#{html}</ul>"
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user