nyastodon/app/lib/admin/metrics/dimension.rb
Matt Jankowski 9f5deb310b
Fix Performance/MapCompact cop (#24797)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2023-05-23 10:49:12 +02:00

22 lines
969 B
Ruby

# frozen_string_literal: true
class Admin::Metrics::Dimension
DIMENSIONS = {
languages: Admin::Metrics::Dimension::LanguagesDimension,
sources: Admin::Metrics::Dimension::SourcesDimension,
servers: Admin::Metrics::Dimension::ServersDimension,
space_usage: Admin::Metrics::Dimension::SpaceUsageDimension,
software_versions: Admin::Metrics::Dimension::SoftwareVersionsDimension,
tag_servers: Admin::Metrics::Dimension::TagServersDimension,
tag_languages: Admin::Metrics::Dimension::TagLanguagesDimension,
instance_accounts: Admin::Metrics::Dimension::InstanceAccountsDimension,
instance_languages: Admin::Metrics::Dimension::InstanceLanguagesDimension,
}.freeze
def self.retrieve(dimension_keys, start_at, end_at, limit, params)
Array(dimension_keys).filter_map do |key|
klass = DIMENSIONS[key.to_sym]
klass&.new(start_at, end_at, limit, klass.with_params? ? params.require(key.to_sym) : nil)
end
end
end