mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit 'd6f2a3ac8d61e0828a17f68a6e9094d0f4662f4c' into glitch-soc/merge-upstream
Conflicts: - `app/views/wrapstodon/show.html.haml`: Conflict because of glitch-soc's theming change. Adapted upstream's changes. - `docker-compose.yml`: Conflict because of container repo name change. Adapted upstream's changes. - `yarn.lock`: Conflict because of an additional glitch-soc dependency. Updated the dependencies upstream did.
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) = ?
|
||||
|
||||
Reference in New Issue
Block a user