2024-01-24 09:38:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AnnualReport::TopStatuses < AnnualReport::Source
|
|
|
|
def generate
|
|
|
|
top_reblogs = base_scope.order(reblogs_count: :desc).first&.id
|
|
|
|
top_favourites = base_scope.where.not(id: top_reblogs).order(favourites_count: :desc).first&.id
|
|
|
|
top_replies = base_scope.where.not(id: [top_reblogs, top_favourites]).order(replies_count: :desc).first&.id
|
|
|
|
|
|
|
|
{
|
|
|
|
top_statuses: {
|
2024-10-31 09:38:00 +00:00
|
|
|
by_reblogs: top_reblogs&.to_s,
|
|
|
|
by_favourites: top_favourites&.to_s,
|
|
|
|
by_replies: top_replies&.to_s,
|
2024-01-24 09:38:10 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_scope
|
2024-09-04 19:50:33 +00:00
|
|
|
report_statuses.public_visibility.joins(:status_stat)
|
2024-01-24 09:38:10 +00:00
|
|
|
end
|
|
|
|
end
|