The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

47 lines
2.1 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.registrations_mode != 'none'
  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(10, filtered: false)
  30. @profile_directory = Setting.profile_directory
  31. @timeline_preview = Setting.timeline_preview
  32. @spam_check_enabled = Setting.spam_check_enabled
  33. end
  34. private
  35. def current_week
  36. @current_week ||= Time.now.utc.to_date.cweek
  37. end
  38. def redis_info
  39. @redis_info ||= Redis.current.info
  40. end
  41. end
  42. end