Module: HireFire::Backend::DelayedJob::ActiveRecord

Defined in:
lib/hirefire/backend/delayed_job/active_record.rb

Instance Method Summary collapse

Instance Method Details

#jobsFixnum

Counts the amount of queued jobs in the database, failed jobs are excluded from the sum

Returns:

  • (Fixnum)

    the amount of pending jobs



13
14
15
16
17
# File 'lib/hirefire/backend/delayed_job/active_record.rb', line 13

def jobs
  ::Delayed::Job.
  where(:failed_at => nil).
  where('run_at <= ?', Time.now).count
end

#workingFixnum

Counts the amount of jobs that are locked by a worker There is no other performant way to determine the amount of workers there currently are

Returns:

  • (Fixnum)

    the amount of (assumably working) workers



25
26
27
28
# File 'lib/hirefire/backend/delayed_job/active_record.rb', line 25

def working
  ::Delayed::Job.
  where('locked_by IS NOT NULL').count
end