cartodb-4.29/lib/carto/metrics/usage_metrics_retriever.rb
2020-06-15 10:58:47 +08:00

26 lines
613 B
Ruby

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