mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-12 23:38:20 +00:00
Remove unused time series details from 2025 annual report (#37187)
This commit is contained in:
@@ -3,29 +3,24 @@
|
||||
class AnnualReport::TimeSeries < AnnualReport::Source
|
||||
def generate
|
||||
{
|
||||
time_series: (1..12).map do |month|
|
||||
{
|
||||
month: month,
|
||||
statuses: statuses_per_month[month] || 0,
|
||||
following: following_per_month[month] || 0,
|
||||
followers: followers_per_month[month] || 0,
|
||||
}
|
||||
end,
|
||||
time_series: [
|
||||
{
|
||||
month: 12,
|
||||
statuses: statuses_this_year,
|
||||
followers: followers_this_year,
|
||||
},
|
||||
],
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def statuses_per_month
|
||||
@statuses_per_month ||= report_statuses.group(:period).pluck(date_part_month.as('period'), Arel.star.count).to_h
|
||||
def statuses_this_year
|
||||
@statuses_this_year ||= report_statuses.count
|
||||
end
|
||||
|
||||
def following_per_month
|
||||
@following_per_month ||= annual_relationships_by_month(@account.active_relationships)
|
||||
end
|
||||
|
||||
def followers_per_month
|
||||
@followers_per_month ||= annual_relationships_by_month(@account.passive_relationships)
|
||||
def followers_this_year
|
||||
@followers_this_year ||= @account.passive_relationships.where(created_in_year, @year).count
|
||||
end
|
||||
|
||||
def date_part_month
|
||||
@@ -34,14 +29,6 @@ class AnnualReport::TimeSeries < AnnualReport::Source
|
||||
SQL
|
||||
end
|
||||
|
||||
def annual_relationships_by_month(relationships)
|
||||
relationships
|
||||
.where(created_in_year, @year)
|
||||
.group(:period)
|
||||
.pluck(date_part_month.as('period'), Arel.star.count)
|
||||
.to_h
|
||||
end
|
||||
|
||||
def created_in_year
|
||||
Arel.sql(<<~SQL.squish)
|
||||
DATE_PART('year', created_at) = ?
|
||||
|
||||
@@ -13,7 +13,7 @@ RSpec.describe AnnualReport::TimeSeries do
|
||||
expect(subject.generate)
|
||||
.to include(
|
||||
time_series: match(
|
||||
include(followers: 0, following: 0, month: 1, statuses: 0)
|
||||
include(followers: 0, month: 12, statuses: 0)
|
||||
)
|
||||
)
|
||||
end
|
||||
@@ -37,7 +37,7 @@ RSpec.describe AnnualReport::TimeSeries do
|
||||
expect(subject.generate)
|
||||
.to include(
|
||||
time_series: match(
|
||||
include(followers: 1, following: 1, month: 1, statuses: 1)
|
||||
include(followers: 1, month: 12, statuses: 1)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user