Module: HireFire::Macro::Deprecated::GoodJob

Included in:
GoodJob
Defined in:
lib/hirefire/macro/deprecated/good_job.rb

Overview

Provides backward compatibility with the deprecated GoodJob macro. For new implementations, refer to GoodJob.

Instance Method Summary collapse

Instance Method Details

#queue(*queues) ⇒ Integer

Retrieves the total number of jobs in the specified queue(s) using GoodJob.

This method queries the PostgreSQL database through GoodJob. It’s capable of counting jobs across different queues or all queues if none specified. The method checks for the existence of ::GoodJob::Execution or ::GoodJob::Job to determine the base class to use for querying.

Examples:

Counting jobs in all queues

HireFire::Macro::GoodJob.queue

Counting jobs in the “default” queue

HireFire::Macro::GoodJob.queue("default")

Parameters:

  • queues (Array<String>)

    The names of the queues to count. Pass an empty array or no arguments to count jobs in all queues.

Returns:

  • (Integer)

    Total number of jobs in the specified queues.



23
24
25
26
27
28
# File 'lib/hirefire/macro/deprecated/good_job.rb', line 23

def queue(*queues)
  base_class = defined?(::GoodJob::Execution) ? ::GoodJob::Execution : ::GoodJob::Job
  scope = base_class.only_scheduled.unfinished
  scope = scope.where(queue_name: queues) if queues.any?
  scope.count
end