Sha256: e929a9626a6ba51278bc896ce62515bd26feee6e3eaad1941e4a3f424d3616f3

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

Contents

# encoding: utf-8

module HireFire
  module Backend
    module DelayedJob
      module Mongoid

        ##
        # Counts the amount of queued jobs in the database,
        # failed jobs and jobs scheduled for the future are excluded
        #
        # @return [Fixnum]
        def jobs
          ::Delayed::Job.where(
            :failed_at  => nil,
            :run_at.lte => Time.now
          ).count
        end

        ##
        # 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
        #
        # @return [Fixnum] the amount of (assumably working) workers
        def working
          ::Delayed::Job.
          where(:locked_by.ne => nil).count
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hirefire-0.1.4 lib/hirefire/backend/delayed_job/mongoid.rb
hirefire-0.1.3 lib/hirefire/backend/delayed_job/mongoid.rb
hirefire-0.1.2 lib/hirefire/backend/delayed_job/mongoid.rb