Class: Peek::Views::Resque

Inherits:
View
  • Object
show all
Defined in:
lib/peek/views/resque.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Resque

Returns a new instance of Resque.



6
7
8
# File 'lib/peek/views/resque.rb', line 6

def initialize(options = {})
  @queues = options.fetch(:queues, ['*'])
end

Instance Method Details

#contextObject



15
16
17
18
19
20
21
# File 'lib/peek/views/resque.rb', line 15

def context
  {
    :jobs => {
      :failures => ::Resque::Failure.count
    }
  }
end

#job_countObject



10
11
12
13
# File 'lib/peek/views/resque.rb', line 10

def job_count
  lookup = @queues == ['*'] ? ::Resque.queues : @queues
  lookup.collect { |queue| ::Resque.size(queue) }.inject(&:+)
end

#resultsObject



23
24
25
# File 'lib/peek/views/resque.rb', line 23

def results
  { :jobs => job_count, :workers => ::Resque.workers.size }
end