You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
2.0 KiB

  1. # frozen_string_literal: true
  2. require 'sidekiq/api'
  3. module Admin
  4. class DashboardController < BaseController
  5. def index
  6. @users_count = User.count
  7. @registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
  8. @logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
  9. @interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
  10. @relay_enabled = Relay.enabled.exists?
  11. @single_user_mode = Rails.configuration.x.single_user_mode
  12. @registrations_enabled = Setting.open_registrations
  13. @deletions_enabled = Setting.open_deletion
  14. @invites_enabled = Setting.min_invite_role == 'user'
  15. @search_enabled = Chewy.enabled?
  16. @version = Mastodon::Version.to_s
  17. @database_version = ActiveRecord::Base.connection.execute('SELECT VERSION()').first['version'].match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
  18. @redis_version = redis_info['redis_version']
  19. @reports_count = Report.unresolved.count
  20. @queue_backlog = Sidekiq::Stats.new.enqueued
  21. @recent_users = User.confirmed.recent.includes(:account).limit(4)
  22. @database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size']
  23. @redis_size = redis_info['used_memory']
  24. @ldap_enabled = ENV['LDAP_ENABLED'] == 'true'
  25. @cas_enabled = ENV['CAS_ENABLED'] == 'true'
  26. @saml_enabled = ENV['SAML_ENABLED'] == 'true'
  27. @pam_enabled = ENV['PAM_ENABLED'] == 'true'
  28. @hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
  29. @trending_hashtags = TrendingTags.get(7)
  30. @profile_directory = Setting.profile_directory
  31. end
  32. private
  33. def current_week
  34. @current_week ||= Time.now.utc.to_date.cweek
  35. end
  36. def redis_info
  37. @redis_info ||= Redis.current.info
  38. end
  39. end
  40. end