module HireFire::Macro::Deprecated::Que

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

Public Instance Methods

queue(*queues) click to toggle source

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

This method queries the PostgreSQL database through Que. It can count jobs in specified queues or all queues if no specific queue is provided. The method determines the base query depending on the Que version detected.

@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::Que.queue

@example Counting jobs in the “default” queue

HireFire::Macro::Que.queue("default")
# File lib/hirefire/macro/deprecated/que.rb, line 22
def queue(*queues)
  query = queues.empty? ? Private.base_query : "#{Private.base_query} AND queue IN (#{Private.names(queues)})"
  results = ::Que.execute(query).first
  (results[:total] || results["total"]).to_i
end