mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-21 10:05:39 +09:00
6e50134a42
* Add trending links * Add overriding specific links trendability * Add link type to preview cards and only trend articles Change trends review notifications from being sent every 5 minutes to being sent every 2 hours Change threshold from 5 unique accounts to 15 unique accounts * Fix tests
42 lines
773 B
Ruby
42 lines
773 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::Metrics::Measure::TagAccountsMeasure < Admin::Metrics::Measure::BaseMeasure
|
|
def self.with_params?
|
|
true
|
|
end
|
|
|
|
def key
|
|
'tag_accounts'
|
|
end
|
|
|
|
def total
|
|
tag.history.aggregate(time_period).accounts
|
|
end
|
|
|
|
def previous_total
|
|
tag.history.aggregate(previous_time_period).accounts
|
|
end
|
|
|
|
def data
|
|
time_period.map { |date| { date: date.to_time(:utc).iso8601, value: tag.history.get(date).accounts.to_s } }
|
|
end
|
|
|
|
protected
|
|
|
|
def tag
|
|
@tag ||= Tag.find(params[:id])
|
|
end
|
|
|
|
def time_period
|
|
(@start_at.to_date..@end_at.to_date)
|
|
end
|
|
|
|
def previous_time_period
|
|
((@start_at.to_date - length_of_period)..(@end_at.to_date - length_of_period))
|
|
end
|
|
|
|
def params
|
|
@params.permit(:id)
|
|
end
|
|
end
|