Sha256: f1cb5e732a0feef1a130c610d723702d7b25049349ef3662debdcd46fb081778

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

# encoding: utf-8

module HireFire
  module Backend
    module DelayedJob
      module ActiveRecord

        ##
        # 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.
          where(:failed_at => nil).
          where('run_at <= ?', 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 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.rb
hirefire-0.1.3 lib/hirefire/backend/delayed_job/active_record.rb
hirefire-0.1.2 lib/hirefire/backend/delayed_job/active_record.rb