Module: HireFire::Backend::DelayedJob::Mongoid

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

Instance Method Summary collapse

Instance Method Details

#jobsFixnum

Counts the amount of queued jobs in the database, failed jobs and jobs scheduled for the future are excluded

Returns:

  • (Fixnum)


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

def jobs
  ::Delayed::Job.where(
    :failed_at  => nil,
    :run_at.lte => 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



26
27
28
29
# File 'lib/hirefire/backend/delayed_job/mongoid.rb', line 26

def working
  ::Delayed::Job.
  where(:locked_by.ne => nil).count
end