measure.rb 1.3 KB

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class Admin::Metrics::Measure
  3. MEASURES = {
  4. active_users: Admin::Metrics::Measure::ActiveUsersMeasure,
  5. new_users: Admin::Metrics::Measure::NewUsersMeasure,
  6. interactions: Admin::Metrics::Measure::InteractionsMeasure,
  7. opened_reports: Admin::Metrics::Measure::OpenedReportsMeasure,
  8. resolved_reports: Admin::Metrics::Measure::ResolvedReportsMeasure,
  9. tag_accounts: Admin::Metrics::Measure::TagAccountsMeasure,
  10. tag_uses: Admin::Metrics::Measure::TagUsesMeasure,
  11. tag_servers: Admin::Metrics::Measure::TagServersMeasure,
  12. instance_accounts: Admin::Metrics::Measure::InstanceAccountsMeasure,
  13. instance_media_attachments: Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure,
  14. instance_reports: Admin::Metrics::Measure::InstanceReportsMeasure,
  15. instance_statuses: Admin::Metrics::Measure::InstanceStatusesMeasure,
  16. instance_follows: Admin::Metrics::Measure::InstanceFollowsMeasure,
  17. instance_followers: Admin::Metrics::Measure::InstanceFollowersMeasure,
  18. }.freeze
  19. def self.retrieve(measure_keys, start_at, end_at, params)
  20. Array(measure_keys).filter_map do |key|
  21. klass = MEASURES[key.to_sym]
  22. klass&.new(start_at, end_at, klass.with_params? ? params.require(key.to_sym) : nil)
  23. end
  24. end
  25. end