Module: HireFire::Macro::Deprecated::Que

Included in:
Que
Defined in:
lib/hirefire/macro/deprecated/que.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#queue(*queues) ⇒ Integer

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.

Examples:

Counting jobs in all queues

HireFire::Macro::Que.queue

Counting jobs in the “default” queue

HireFire::Macro::Que.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.



22
23
24
25
26
# 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