class Sidekiq::History::RedisStatistic

Public Class Methods

new(start_date, end_date) click to toggle source
# File lib/sidekiq/history/statistic/redis_statistic.rb, line 4
def initialize(start_date, end_date)
  @start_date = start_date
  @end_date = end_date
end

Public Instance Methods

for_worker(worker) click to toggle source
# File lib/sidekiq/history/statistic/redis_statistic.rb, line 9
def for_worker(worker)
  hash.map{ |h| h.values.first[worker] || {} }
end
hash() click to toggle source
# File lib/sidekiq/history/statistic/redis_statistic.rb, line 17
def hash
  @redis_hash = Sidekiq.redis do |conn|
    (@end_date..@start_date).map do |date|
      {
        date.to_s => parse(conn.hgetall("sidekiq:history:#{date}"))
      }
    end
  end
end
worker_names() click to toggle source
# File lib/sidekiq/history/statistic/redis_statistic.rb, line 13
def worker_names
  @worker_names ||= hash.flat_map{ |hash| hash.values.first.keys }.uniq
end

Private Instance Methods

parse(hash) click to toggle source
# File lib/sidekiq/history/statistic/redis_statistic.rb, line 29
def parse(hash)
  hash.each do |worker, json|
    hash[worker] = Sidekiq.load_json(json).symbolize_keys
  end
end