mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 16:03:42 +01:00
6e50134a42
* Add trending links * Add overriding specific links trendability * Add link type to preview cards and only trend articles Change trends review notifications from being sent every 5 minutes to being sent every 2 hours Change threshold from 5 unique accounts to 15 unique accounts * Fix tests
25 lines
668 B
Ruby
25 lines
668 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::Metrics::Dimension::LanguagesDimension < Admin::Metrics::Dimension::BaseDimension
|
|
include LanguagesHelper
|
|
|
|
def key
|
|
'languages'
|
|
end
|
|
|
|
def data
|
|
sql = <<-SQL.squish
|
|
SELECT locale, count(*) AS value
|
|
FROM users
|
|
WHERE current_sign_in_at BETWEEN $1 AND $2
|
|
AND locale IS NOT NULL
|
|
GROUP BY locale
|
|
ORDER BY count(*) DESC
|
|
LIMIT $3
|
|
SQL
|
|
|
|
rows = ActiveRecord::Base.connection.select_all(sql, nil, [[nil, @start_at], [nil, @end_at], [nil, @limit]])
|
|
|
|
rows.map { |row| { key: row['locale'], human_key: human_locale(row['locale']), value: row['value'].to_s } }
|
|
end
|
|
end
|