Class: SidekiqJobStats::Statistic

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_class) ⇒ Statistic

Returns a new instance of Statistic.



33
34
35
# File 'lib/sidekiq_job_stats/statistic.rb', line 33

def initialize(job_class)
  self.job_class = job_class
end

Instance Attribute Details

#job_classObject

DEFAULT_STATS = [:jobs_enqueued, :jobs_performed_day, :jobs_performed_month,

:job_rolling_avg_day, :job_rolling_avg_month,
:longest_job_day, :longest_job_month, :job_memory_usage_avg_day,
:job_memory_usage_avg_month, :peak_memory_usage_day,
:peak_memory_usage_month]


10
11
12
# File 'lib/sidekiq_job_stats/statistic.rb', line 10

def job_class
  @job_class
end

Class Method Details

.all_jobs_classesObject



24
25
26
27
28
29
30
31
# File 'lib/sidekiq_job_stats/statistic.rb', line 24

def self.all_jobs_classes
  subclasses = []
  ObjectSpace.each_object(Class) do |sub_class|
    next unless sub_class < Sidekiq::Worker
    subclasses << sub_class
  end
  subclasses
end

.find_allObject



20
21
22
# File 'lib/sidekiq_job_stats/statistic.rb', line 20

def self.find_all
  all_jobs_classes.map{|j| new(j)}
end

Instance Method Details

#<=>(other) ⇒ Object



37
38
39
# File 'lib/sidekiq_job_stats/statistic.rb', line 37

def <=>(other)
  self.name <=> other.name
end