Module: HireFire::Macro::Que

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

Instance Method Summary collapse

Instance Method Details

#queue(queue = nil) ⇒ Integer

Queries the PostgreSQL database through Que in order to count the amount of jobs in the specified queue.

Examples:

Queue Macro Usage

HireFire::Macro::Que.queue # counts all queues.
HireFire::Macro::Que.queue("email") # counts the `email` queue.

Parameters:

  • queue (String) (defaults to: nil)

    the queue name to count. (default: nil # gets all queues)

Returns:

  • (Integer)

    the number of jobs in the queue(s).



18
19
20
21
22
23
# File 'lib/hirefire/macro/que.rb', line 18

def queue(queue = nil)
  query = ::Que::Web::SQL[:dashboard_stats]
  query = "#{query} WHERE queue = '#{queue}'" if queue
  results = ::Que.execute(query).first
  results["total"].to_i - results["failing"].to_i
end