mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-26 07:51:37 +01:00
22 lines
618 B
Ruby
22 lines
618 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AnnualReport::MostUsedApps < AnnualReport::Source
|
|
SET_SIZE = 10
|
|
|
|
def generate
|
|
{
|
|
most_used_apps: most_used_apps.map do |(name, count)|
|
|
{
|
|
name: name,
|
|
count: count,
|
|
}
|
|
end,
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def most_used_apps
|
|
@account.statuses.reorder(nil).where(id: year_as_snowflake_range).joins(:application).group('oauth_applications.name').order(total: :desc).limit(SET_SIZE).pluck(Arel.sql('oauth_applications.name, count(*) as total'))
|
|
end
|
|
end
|