mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Mark private
methods in AnnualReport::TopStatuses
(#35256)
This commit is contained in:
parent
1496488771
commit
ad78701b6f
|
@ -2,20 +2,44 @@
|
||||||
|
|
||||||
class AnnualReport::TopStatuses < AnnualReport::Source
|
class AnnualReport::TopStatuses < AnnualReport::Source
|
||||||
def generate
|
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: {
|
top_statuses: {
|
||||||
by_reblogs: top_reblogs&.to_s,
|
by_reblogs: status_identifier(most_reblogged_status),
|
||||||
by_favourites: top_favourites&.to_s,
|
by_favourites: status_identifier(most_favourited_status),
|
||||||
by_replies: top_replies&.to_s,
|
by_replies: status_identifier(most_replied_status),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def status_identifier(status)
|
||||||
|
status.id.to_s if status.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def most_reblogged_status
|
||||||
|
base_scope
|
||||||
|
.order(reblogs_count: :desc)
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def most_favourited_status
|
||||||
|
base_scope
|
||||||
|
.excluding(most_reblogged_status)
|
||||||
|
.order(favourites_count: :desc)
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def most_replied_status
|
||||||
|
base_scope
|
||||||
|
.excluding(most_reblogged_status, most_favourited_status)
|
||||||
|
.order(replies_count: :desc)
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
|
||||||
def base_scope
|
def base_scope
|
||||||
report_statuses.public_visibility.joins(:status_stat)
|
report_statuses
|
||||||
|
.public_visibility
|
||||||
|
.joins(:status_stat)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user