2021-10-15 03:44:59 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::Metrics::Measure
|
|
|
|
MEASURES = {
|
|
|
|
active_users: Admin::Metrics::Measure::ActiveUsersMeasure,
|
|
|
|
new_users: Admin::Metrics::Measure::NewUsersMeasure,
|
|
|
|
interactions: Admin::Metrics::Measure::InteractionsMeasure,
|
|
|
|
opened_reports: Admin::Metrics::Measure::OpenedReportsMeasure,
|
|
|
|
resolved_reports: Admin::Metrics::Measure::ResolvedReportsMeasure,
|
2021-11-25 21:07:38 +09:00
|
|
|
tag_accounts: Admin::Metrics::Measure::TagAccountsMeasure,
|
|
|
|
tag_uses: Admin::Metrics::Measure::TagUsesMeasure,
|
|
|
|
tag_servers: Admin::Metrics::Measure::TagServersMeasure,
|
2022-03-09 16:52:32 +09:00
|
|
|
instance_accounts: Admin::Metrics::Measure::InstanceAccountsMeasure,
|
|
|
|
instance_media_attachments: Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure,
|
|
|
|
instance_reports: Admin::Metrics::Measure::InstanceReportsMeasure,
|
|
|
|
instance_statuses: Admin::Metrics::Measure::InstanceStatusesMeasure,
|
|
|
|
instance_follows: Admin::Metrics::Measure::InstanceFollowsMeasure,
|
|
|
|
instance_followers: Admin::Metrics::Measure::InstanceFollowersMeasure,
|
2021-10-15 03:44:59 +09:00
|
|
|
}.freeze
|
|
|
|
|
2021-11-25 21:07:38 +09:00
|
|
|
def self.retrieve(measure_keys, start_at, end_at, params)
|
2023-05-23 17:49:12 +09:00
|
|
|
Array(measure_keys).filter_map do |key|
|
2021-11-25 21:07:38 +09:00
|
|
|
klass = MEASURES[key.to_sym]
|
|
|
|
klass&.new(start_at, end_at, klass.with_params? ? params.require(key.to_sym) : nil)
|
2023-05-23 17:49:12 +09:00
|
|
|
end
|
2021-10-15 03:44:59 +09:00
|
|
|
end
|
|
|
|
end
|