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.

57 lines
2.5 KiB

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