Sha256: fb08de9fa3f7221e1ba39535a377c7796422c9d4c0f5fda23eb26e26ae829103

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

Que::Web::SQL = {
  :dashboard_stats => %{
      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,
  :failing_jobs => %{
      SELECT que_jobs.*
      FROM que_jobs
      LEFT JOIN (
        SELECT (classid::bigint << 32) + objid::bigint AS job_id
        FROM pg_locks
        WHERE locktype = 'advisory'
      ) locks USING (job_id)
      WHERE locks.job_id IS NULL AND error_count > 0
      ORDER BY run_at
      LIMIT $1::int
      OFFSET $2::int
  }.freeze,
  :scheduled_jobs => %{
      SELECT que_jobs.*
      FROM que_jobs
      LEFT JOIN (
        SELECT (classid::bigint << 32) + objid::bigint AS job_id
        FROM pg_locks
        WHERE locktype = 'advisory'
      ) locks USING (job_id)
      WHERE locks.job_id IS NULL AND error_count = 0
      ORDER BY run_at
      LIMIT $1::int
      OFFSET $2::int
  }.freeze,
  :delete_job => %{
      DELETE
      FROM que_jobs
      WHERE job_id = $1::bigint
  }.freeze,
  :reschedule_job => %{
      UPDATE que_jobs
      SET run_at = $2::timestamptz
      WHERE job_id = $1::bigint
  }.freeze,
  :fetch_job => %{
      SELECT *
      FROM que_jobs
      WHERE job_id = $1::bigint
      LIMIT 1
  }.freeze,
}.freeze

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
que-web-0.4.0 lib/que/web/sql.rb
que-web-0.3.2 lib/que/web/sql.rb
que-web-0.3.1 lib/que/web/sql.rb
que-web-0.3.0 lib/que/web/sql.rb
que-web-0.2.2 lib/que/web/sql.rb