]> cat aescling's git repositories - mastodon.git/blob - app/controllers/admin/dashboard_controller.rb
Display trending hashtags on admin dashboard (#8038)
[mastodon.git] / app / controllers / admin / dashboard_controller.rb
1 # frozen_string_literal: true
2 require 'sidekiq/api'
3
4 module Admin
5 class DashboardController < BaseController
6 def index
7 @users_count = User.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.open_registrations
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(4)
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(7)
31 end
32
33 private
34
35 def current_week
36 @current_week ||= Time.now.utc.to_date.cweek
37 end
38
39 def redis_info
40 @redis_info ||= Redis.current.info
41 end
42 end
43 end
This page took 0.090686 seconds and 4 git commands to generate.