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

Includes:
Helpers::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

Methods included from Helpers::GoodJob

#error_event_supported?, #good_job_class, included

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.



27
28
29
30
31
# File 'lib/hirefire/macro/deprecated/good_job.rb', line 27

def queue(*queues)
  scope = good_job_class.only_scheduled.unfinished
  scope = scope.where(queue_name: queues) if queues.any?
  scope.count
end