Sha256: e26519ddedd7badd9cb1841eb13ecbd814d011a7964d8ed2600cae2f7f0bc5cf

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

# encoding: utf-8

module HireFire
  module Backend
    module DelayedJob
      module ActiveRecord2

        ##
        # Counts the amount of queued jobs in the database,
        # failed jobs are excluded from the sum
        #
        # @return [Fixnum] the amount of pending jobs
        def jobs
          ::Delayed::Job.all(
            :conditions => ['failed_at IS NULL and run_at <= ?', Time.now.utc]
          ).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.all(
            :conditions => 'locked_by IS NOT NULL'
          ).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/active_record_2.rb
hirefire-0.1.3 lib/hirefire/backend/delayed_job/active_record_2.rb
hirefire-0.1.2 lib/hirefire/backend/delayed_job/active_record_2.rb