about summary refs log tree commit diff
path: root/app/lib/admin/metrics/measure.rb
blob: 0b510eb25691c78260eb64643d924178bd9729df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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,
    tag_accounts: Admin::Metrics::Measure::TagAccountsMeasure,
    tag_uses: Admin::Metrics::Measure::TagUsesMeasure,
    tag_servers: Admin::Metrics::Measure::TagServersMeasure,
    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,
  }.freeze

  def self.retrieve(measure_keys, start_at, end_at, params)
    Array(measure_keys).map do |key|
      klass = MEASURES[key.to_sym]
      klass&.new(start_at, end_at, klass.with_params? ? params.require(key.to_sym) : nil)
    end.compact
  end
end