class Sidekiq::Stats::History
Public Class Methods
new(days_previous, start_date = nil)
click to toggle source
# File lib/sidekiq/api.rb, line 140 def initialize(days_previous, start_date = nil) @days_previous = days_previous @start_date = start_date || Time.now.utc.to_date end
Public Instance Methods
failed()
click to toggle source
# File lib/sidekiq/api.rb, line 149 def failed date_stat_hash("failed") end
processed()
click to toggle source
# File lib/sidekiq/api.rb, line 145 def processed date_stat_hash("processed") end
Private Instance Methods
date_stat_hash(stat)
click to toggle source
# File lib/sidekiq/api.rb, line 155 def date_stat_hash(stat) i = 0 stat_hash = {} keys = [] dates = [] while i < @days_previous date = @start_date - i datestr = date.strftime("%Y-%m-%d".freeze) keys << "stat:#{stat}:#{datestr}" dates << datestr i += 1 end Sidekiq.redis do |conn| conn.mget(keys).each_with_index do |value, idx| stat_hash[dates[idx]] = value ? value.to_i : 0 end end stat_hash end