2013-03-19 22:18:00 -05:00
|
|
|
class AdminDashboardData
|
|
|
|
|
|
|
|
REPORTS = ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level', 'likes', 'emails']
|
|
|
|
|
|
|
|
def self.fetch
|
|
|
|
AdminDashboardData.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def as_json
|
|
|
|
@json ||= {
|
|
|
|
reports: REPORTS.map { |type| Report.find(type) },
|
2013-03-21 15:51:19 -05:00
|
|
|
problems: [rails_env_check, host_names_check, gc_checks, clockwork_check].compact
|
2013-03-19 22:18:00 -05:00
|
|
|
}.merge(
|
|
|
|
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rails_env_check
|
|
|
|
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env == 'production'
|
|
|
|
end
|
2013-03-20 14:38:28 -05:00
|
|
|
|
|
|
|
def host_names_check
|
|
|
|
I18n.t("dashboard.host_names_warning") if ['localhost', 'production.localhost'].include?(Discourse.current_hostname)
|
|
|
|
end
|
2013-03-20 15:16:23 -05:00
|
|
|
|
|
|
|
def gc_checks
|
|
|
|
I18n.t("dashboard.gc_warning") if ENV['RUBY_GC_MALLOC_LIMIT'].nil?
|
|
|
|
end
|
2013-03-21 15:51:19 -05:00
|
|
|
|
|
|
|
def clockwork_check
|
|
|
|
I18n.t('dashboard.clockwork_warning') unless Jobs::ClockworkHeartbeat.is_clockwork_running?
|
|
|
|
end
|
2013-03-19 22:18:00 -05:00
|
|
|
end
|