Class: Resque::Plugins::JobStats::Statistic

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/resque/plugins/job_stats/statistic.rb

Overview

A class composed of a job class and the various job statistics collected for the given job.

Constant Summary collapse

DEFAULT_STATS =

An array of the default statistics that will be displayed in the web tab

[:jobs_enqueued, :jobs_performed, :jobs_failed, :job_rolling_avg, :longest_job]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_class, metrics) ⇒ Statistic

A series of metrics describing one job class.



22
23
24
25
# File 'lib/resque/plugins/job_stats/statistic.rb', line 22

def initialize(job_class, metrics)
  self.job_class = job_class
  self.load(metrics)
end

Class Method Details

.find_all(metrics) ⇒ Object

Find and load a Statistic for all resque jobs that are in the Resque::Plugins::JobStats.measured_jobs collection



16
17
18
# File 'lib/resque/plugins/job_stats/statistic.rb', line 16

def find_all(metrics)
  Resque::Plugins::JobStats.measured_jobs.map{|j| new(j, metrics)}
end

Instance Method Details

#<=>(other) ⇒ Object



37
38
39
# File 'lib/resque/plugins/job_stats/statistic.rb', line 37

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

#load(metrics) ⇒ Object



27
28
29
30
31
# File 'lib/resque/plugins/job_stats/statistic.rb', line 27

def load(metrics)
  metrics.each do |metric|
    self.send("#{metric}=", job_class.send(metric))
  end
end

#nameObject



33
34
35
# File 'lib/resque/plugins/job_stats/statistic.rb', line 33

def name
  self.job_class.name
end