2018-07-15 23:11:53 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'sidekiq/api'
|
|
|
|
|
|
|
|
module Admin
|
|
|
|
class DashboardController < BaseController
|
2021-03-26 17:22:54 +00:00
|
|
|
SIDEKIQ_QUEUES = %w(default push mailers pull scheduler).freeze
|
|
|
|
|
2018-07-15 23:11:53 +00:00
|
|
|
def index
|
2021-03-26 17:22:54 +00:00
|
|
|
missing_queues = Sidekiq::ProcessSet.new.reduce(SIDEKIQ_QUEUES) { |queues, process| queues - process['queues'] }
|
|
|
|
|
|
|
|
flash.now[:alert] = I18n.t('admin.dashboard.misconfigured_sidekiq_alert', queues: missing_queues.join(', ')) unless missing_queues.empty?
|
|
|
|
|
2018-07-15 23:11:53 +00:00
|
|
|
@users_count = User.count
|
2019-08-07 14:13:34 +00:00
|
|
|
@pending_users_count = User.pending.count
|
2018-07-15 23:11:53 +00:00
|
|
|
@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
|
2019-03-14 04:28:30 +00:00
|
|
|
@registrations_enabled = Setting.registrations_mode != 'none'
|
2018-07-15 23:58:10 +00:00
|
|
|
@deletions_enabled = Setting.open_deletion
|
2018-07-15 23:11:53 +00:00
|
|
|
@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
|
2019-08-07 14:13:34 +00:00
|
|
|
@recent_users = User.confirmed.recent.includes(:account).limit(8)
|
2018-07-15 23:11:53 +00:00
|
|
|
@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'
|
2019-08-05 17:54:29 +00:00
|
|
|
@trending_hashtags = TrendingTags.get(10, filtered: false)
|
2019-08-07 14:13:34 +00:00
|
|
|
@pending_tags_count = Tag.pending_review.count
|
2019-08-06 17:40:06 +00:00
|
|
|
@authorized_fetch = authorized_fetch_mode?
|
|
|
|
@whitelist_enabled = whitelist_mode?
|
2018-12-11 18:18:29 +00:00
|
|
|
@profile_directory = Setting.profile_directory
|
2019-03-26 00:24:19 +00:00
|
|
|
@timeline_preview = Setting.timeline_preview
|
2019-07-17 19:09:15 +00:00
|
|
|
@spam_check_enabled = Setting.spam_check_enabled
|
2019-08-06 17:40:06 +00:00
|
|
|
@trends_enabled = Setting.trends
|
2018-07-15 23:11:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def current_week
|
|
|
|
@current_week ||= Time.now.utc.to_date.cweek
|
|
|
|
end
|
|
|
|
|
|
|
|
def redis_info
|
2019-08-06 17:40:06 +00:00
|
|
|
@redis_info ||= begin
|
|
|
|
if Redis.current.is_a?(Redis::Namespace)
|
|
|
|
Redis.current.redis.info
|
|
|
|
else
|
|
|
|
Redis.current.info
|
|
|
|
end
|
|
|
|
end
|
2018-07-15 23:11:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|