Change design of federation pages in admin UI (#17704)
* Change design of federation pages in admin UI * Fix query performance in instance media attachments measure * Fix reblogs being included in instance languages dimension
This commit is contained in:
parent
318d34d528
commit
bd53dd5210
32 changed files with 712 additions and 235 deletions
|
@ -0,0 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::Metrics::Dimension::InstanceAccountsDimension < Admin::Metrics::Dimension::BaseDimension
|
||||
include LanguagesHelper
|
||||
|
||||
def self.with_params?
|
||||
true
|
||||
end
|
||||
|
||||
def key
|
||||
'instance_accounts'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def perform_query
|
||||
sql = <<-SQL.squish
|
||||
SELECT accounts.username, count(follows.*) AS value
|
||||
FROM accounts
|
||||
LEFT JOIN follows ON follows.target_account_id = accounts.id
|
||||
WHERE accounts.domain = $1
|
||||
GROUP BY accounts.id, follows.target_account_id
|
||||
ORDER BY value DESC
|
||||
LIMIT $2
|
||||
SQL
|
||||
|
||||
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, params[:domain]], [nil, @limit]])
|
||||
|
||||
rows.map { |row| { key: row['username'], human_key: row['username'], value: row['value'].to_s } }
|
||||
end
|
||||
|
||||
def params
|
||||
@params.permit(:domain)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue