cartodb-4.42/lib/carto/metrics/usage_metrics_retriever.rb

26 lines
613 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
require_relative 'usage_metrics_interface'
module Carto::Metrics
class UsageMetricsRetriever
def initialize(cls)
@cls = cls
end
def services
@cls::VALID_SERVICES
end
def metrics
@cls::VALID_METRICS
end
def get_range(user, org, service, metric, date_from, date_to)
usage_metrics = @cls.new(user.try(:username), org.try(:name))
if !usage_metrics.is_a? UsageMetricsInterface
raise "#{usage_metrics.class} shall implement UsageMetricsInterface"
end
usage_metrics.get_date_range(service, metric, date_from, date_to)
end
end
end