module HireFire::Macro::Deprecated::GoodJob

Provides backward compatibility with the deprecated GoodJob macro. For new implementations, refer to {HireFire::Macro::GoodJob}.

Public Instance Methods

queue(*queues) click to toggle source

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.

@param queues [Array<String>] The names of the queues to count.

Pass an empty array or no arguments to count jobs in all queues.

@return [Integer] Total number of jobs in the specified queues. @example Counting jobs in all queues

HireFire::Macro::GoodJob.queue

@example Counting jobs in the “default” queue

HireFire::Macro::GoodJob.queue("default")
# 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