Class: SidekiqJobStats::History

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_job_stats/history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_class) ⇒ History

Returns a new instance of History.



5
6
7
# File 'lib/sidekiq_job_stats/history.rb', line 5

def initialize(job_class)
  @job_class = job_class
end

Instance Attribute Details

#job_classObject

Returns the value of attribute job_class.



3
4
5
# File 'lib/sidekiq_job_stats/history.rb', line 3

def job_class
  @job_class
end

Instance Method Details

#histories_recordableObject



13
14
15
# File 'lib/sidekiq_job_stats/history.rb', line 13

def histories_recordable
  @histories_recordable || 100
end

#histories_recordedObject



23
24
25
26
27
# File 'lib/sidekiq_job_stats/history.rb', line 23

def histories_recorded
  Sidekiq.redis do |conn|
    conn.llen(job_history_key)
  end
end

#job_histories(start = 0, limit = 100) ⇒ Object



17
18
19
20
21
# File 'lib/sidekiq_job_stats/history.rb', line 17

def job_histories(start = 0, limit = 100)
  Sidekiq.redis do |conn|
    conn.lrange(job_history_key, start, start + limit - 1).map { |h| JSON.parse(h) }
  end
end

#track(job_data) ⇒ Object



9
10
11
# File 'lib/sidekiq_job_stats/history.rb', line 9

def track(job_data)
  push_history(job_data)
end