dimension.rb 969 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. class Admin::Metrics::Dimension
  3. DIMENSIONS = {
  4. languages: Admin::Metrics::Dimension::LanguagesDimension,
  5. sources: Admin::Metrics::Dimension::SourcesDimension,
  6. servers: Admin::Metrics::Dimension::ServersDimension,
  7. space_usage: Admin::Metrics::Dimension::SpaceUsageDimension,
  8. software_versions: Admin::Metrics::Dimension::SoftwareVersionsDimension,
  9. tag_servers: Admin::Metrics::Dimension::TagServersDimension,
  10. tag_languages: Admin::Metrics::Dimension::TagLanguagesDimension,
  11. instance_accounts: Admin::Metrics::Dimension::InstanceAccountsDimension,
  12. instance_languages: Admin::Metrics::Dimension::InstanceLanguagesDimension,
  13. }.freeze
  14. def self.retrieve(dimension_keys, start_at, end_at, limit, params)
  15. Array(dimension_keys).filter_map do |key|
  16. klass = DIMENSIONS[key.to_sym]
  17. klass&.new(start_at, end_at, limit, klass.with_params? ? params.require(key.to_sym) : nil)
  18. end
  19. end
  20. end