32 lines
603 B
Ruby
32 lines
603 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AnnualReport::TimeSeries < AnnualReport::Source
|
|
def generate
|
|
{
|
|
time_series: [
|
|
{
|
|
month: 12,
|
|
statuses: statuses_this_year,
|
|
followers: followers_this_year,
|
|
},
|
|
],
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def statuses_this_year
|
|
@statuses_this_year ||= report_statuses.count
|
|
end
|
|
|
|
def followers_this_year
|
|
@followers_this_year ||= @account.passive_relationships.where(created_in_year, @year).count
|
|
end
|
|
|
|
def created_in_year
|
|
Arel.sql(<<~SQL.squish)
|
|
DATE_PART('year', created_at) = ?
|
|
SQL
|
|
end
|
|
end
|