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. @users_count = User.count
  7. @pending_users_count = User.pending.count
  8. @registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
  9. @logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
  10. @interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
  11. @relay_enabled = Relay.enabled.exists?
  12. @single_user_mode = Rails.configuration.x.single_user_mode
  13. @registrations_enabled = Setting.registrations_mode != 'none'
  14. @deletions_enabled = Setting.open_deletion
  15. @invites_enabled = Setting.min_invite_role == 'user'
  16. @search_enabled = Chewy.enabled?
  17. @version = Mastodon::Version.to_s
  18. @database_version = ActiveRecord::Base.connection.execute('SELECT VERSION()').first['version'].match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
  19. @redis_version = redis_info['redis_version']
  20. @reports_count = Report.unresolved.count
  21. @queue_backlog = Sidekiq::Stats.new.enqueued
  22. @recent_users = User.confirmed.recent.includes(:account).limit(8)
  23. @database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size']
  24. @redis_size = redis_info['used_memory']
  25. @ldap_enabled = ENV['LDAP_ENABLED'] == 'true'
  26. @cas_enabled = ENV['CAS_ENABLED'] == 'true'
  27. @saml_enabled = ENV['SAML_ENABLED'] == 'true'
  28. @pam_enabled = ENV['PAM_ENABLED'] == 'true'
  29. @hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
  30. @trending_hashtags = TrendingTags.get(10, filtered: false)
  31. @pending_tags_count = Tag.pending_review.count
  32. @authorized_fetch = authorized_fetch_mode?
  33. @whitelist_enabled = whitelist_mode?
  34. @profile_directory = Setting.profile_directory
  35. @timeline_preview = Setting.timeline_preview
  36. @spam_check_enabled = Setting.spam_check_enabled
  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