Sha256: fba4d5f32221ede8ea68913bb94347eb375bc0efa5107ea95d3c977e2635056e

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Stats
    module Operations
      module Timeseries
        class Values
          attr_reader :key, :range

          def initialize(**keywords)
            @key = keywords.fetch(:key)
            @from = keywords.fetch(:from)
            @to = keywords.fetch(:to)
            @range = keywords.fetch(:range)
            @config = keywords[:config]
          end

          def config
            @config || Trifle::Stats.default
          end

          def timeline
            Nocturnal.timeline(from: @from, to: @to, range: range)
          end

          def perform
            {
              at: timeline,
              values: config.driver.get(
                keys: timeline.map do |at|
                  [key, range, at.to_i]
                end
              )
            }
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trifle-stats-1.3.1 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-1.3.0 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-1.2.0 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-1.1.2 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-1.1.1 lib/trifle/stats/operations/timeseries/values.rb
trifle-stats-1.0.0 lib/trifle/stats/operations/timeseries/values.rb