diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-07-17 22:05:25 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-07-17 22:05:25 +0200 |
commit | 7dbed4dab93d3eaf79b7e7e4a61f52782909d1ae (patch) | |
tree | 7a235fc9422d71f56993b4682b06439310f21f65 /app/controllers/admin/dashboard_controller.rb | |
parent | 1fb78602c56b7bf52dcf383fea7a4c45ce568655 (diff) | |
parent | 6277a6db2a70b798aed71ff7e722d23b975182cd (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/controllers/admin/dashboard_controller.rb')
-rw-r--r-- | app/controllers/admin/dashboard_controller.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 000000000..7be753c9b --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true +require 'sidekiq/api' + +module Admin + class DashboardController < BaseController + def index + @users_count = User.count + @registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0 + @logins_week = Redis.current.pfcount("activity:logins:#{current_week}") + @interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0 + @relay_enabled = Relay.enabled.exists? + @single_user_mode = Rails.configuration.x.single_user_mode + @registrations_enabled = Setting.open_registrations + @deletions_enabled = Setting.open_deletion + @invites_enabled = Setting.min_invite_role == 'user' + @search_enabled = Chewy.enabled? + @version = Mastodon::Version.to_s + @database_version = ActiveRecord::Base.connection.execute('SELECT VERSION()').first['version'].match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1] + @redis_version = redis_info['redis_version'] + @reports_count = Report.unresolved.count + @queue_backlog = Sidekiq::Stats.new.enqueued + @recent_users = User.confirmed.recent.includes(:account).limit(4) + @database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size'] + @redis_size = redis_info['used_memory'] + @ldap_enabled = ENV['LDAP_ENABLED'] == 'true' + @cas_enabled = ENV['CAS_ENABLED'] == 'true' + @saml_enabled = ENV['SAML_ENABLED'] == 'true' + @pam_enabled = ENV['PAM_ENABLED'] == 'true' + @hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true' + @trending_hashtags = TrendingTags.get(7) + end + + private + + def current_week + @current_week ||= Time.now.utc.to_date.cweek + end + + def redis_info + @redis_info ||= Redis.current.info + end + end +end |