class DelayedJobUi::Jobs

Public Class Methods

job_count() click to toggle source
# File lib/delayed_job_ui/jobs.rb, line 19
def self.job_count
  count_hash = {:enqueued => 0, :working => 0, :pending => 0, :failed => 0}
  count_hash.each do |type, number|
    count_hash[type] = self.jobs(type).count
  end
  count_hash
end
jobs(type) click to toggle source
# File lib/delayed_job_ui/jobs.rb, line 3
def self.jobs(type)
  case type
  when :working
    query = "locked_at IS NOT NULL"
  when :failed
    query = "last_error IS NOT NULL"
  when :pending
    query = "attempts = 0 AND locked_at IS NULL"
  end
  if defined? query
    Delayed::Job.where(query)
  else
    Delayed::Job.all
  end
end