Sha256: d7ce99be247e179a0bf62e2b9f37f3dfe9bf8c7f9a15210c39944ca1286a25de

Contents?: true

Size: 824 Bytes

Versions: 5

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Stats
    module Operations
      module Timeseries
        class Increment
          attr_reader :key, :values

          def initialize(**keywords)
            @key = keywords.fetch(:key)
            @at = keywords.fetch(:at)
            @values = keywords.fetch(:values)
            @config = keywords[:config]
          end

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

          def key_for(range:)
            at = Nocturnal.new(@at, config: config).send(range)
            [key, range, at.to_i]
          end

          def perform
            config.driver.inc(
              keys: config.ranges.map { |range| key_for(range: range) },
              **values
            )
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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