savonarola/pulse_meter_core

View on GitHub
lib/pulse_meter/sensor/timelined/max.rb

Summary

Maintainability
A
15 mins
Test Coverage
module PulseMeter
  module Sensor
    module Timelined
      # Calculates max value in interval
      class Max < ZSetBased

        def update(key)
          command_aggregator.zremrangebyrank(key, 0, -2)
        end

        def calculate(key, _)
          max_el = redis.zrange(key, -1, -1)[0]
          redis.zscore(key, max_el)
        end

      end
    end
  end
end