2024-01-24 18:38:10 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AnnualReport::Source
|
|
|
|
attr_reader :account, :year
|
|
|
|
|
|
|
|
def initialize(account, year)
|
|
|
|
@account = account
|
|
|
|
@year = year
|
|
|
|
end
|
|
|
|
|
2024-11-04 19:11:06 +09:00
|
|
|
def self.prepare(_year)
|
|
|
|
# Use this method if any pre-calculations must be made before individual annual reports are generated
|
|
|
|
end
|
|
|
|
|
|
|
|
def generate
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2024-01-24 18:38:10 +09:00
|
|
|
protected
|
|
|
|
|
2024-09-05 04:50:33 +09:00
|
|
|
def report_statuses
|
|
|
|
@account
|
|
|
|
.statuses
|
|
|
|
.where(id: year_as_snowflake_range)
|
|
|
|
.reorder(nil)
|
|
|
|
end
|
|
|
|
|
2024-01-24 18:38:10 +09:00
|
|
|
def year_as_snowflake_range
|
2024-09-05 02:19:53 +09:00
|
|
|
(beginning_snowflake_id..ending_snowflake_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def beginning_snowflake_id
|
|
|
|
Mastodon::Snowflake.id_at DateTime.new(year).beginning_of_year
|
|
|
|
end
|
|
|
|
|
|
|
|
def ending_snowflake_id
|
|
|
|
Mastodon::Snowflake.id_at DateTime.new(year).end_of_year
|
2024-01-24 18:38:10 +09:00
|
|
|
end
|
|
|
|
end
|