Module: HireFire::Macro::Que
Constant Summary collapse
- QUERY =
%{ SELECT count(*) AS total, count(locks.job_id) AS running, coalesce(sum((error_count > 0 AND locks.job_id IS NULL)::int), 0) AS failing, coalesce(sum((error_count = 0 AND locks.job_id IS NULL)::int), 0) AS scheduled FROM que_jobs LEFT JOIN ( SELECT (classid::bigint << 32) + objid::bigint AS job_id FROM pg_locks WHERE locktype = 'advisory' ) locks USING (job_id) }.freeze
Instance Method Summary collapse
-
#queue(queue = nil) ⇒ Integer
Queries the PostgreSQL database through Que in order to count the amount of jobs in the specified queue.
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.
28 29 30 31 32 |
# File 'lib/hirefire/macro/que.rb', line 28 def queue(queue = nil) query = queue ? "#{QUERY} WHERE queue = '#{queue}'" : QUERY results = ::Que.execute(query).first results["total"].to_i - results["failing"].to_i end |