Class: PgCron::Adapters::Postgres::Jobs Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_cron/adapters/postgres/jobs.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Fetches scheduled jobs from the postgres connection.

The F(x) counterpart is Adapters::Postgres::Functions, which reads pg_proc. This reads cron.job — pg_cron's own catalogue.

Constant Summary collapse

JOBS_WITH_DEFINITIONS_QUERY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The query used to retrieve the jobs considered dumpable into db/schema.rb.

jobname can be NULL: cron.schedule() has an arity that does not take one. Such a job cannot be expressed as create_cron_job, which is keyed by name, so it is excluded rather than dumped wrongly.

<<~SQL.freeze
  SELECT
      jobname,
      schedule,
      command,
      database,
      username,
      active
  FROM cron.job
  WHERE jobname IS NOT NULL
  ORDER BY jobname;
SQL

Class Method Summary collapse

Class Method Details

.all(connection) ⇒ Array<PgCron::Job>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wraps #all as a static facade.

Returns:



38
39
40
41
42
43
44
# File 'lib/pg_cron/adapters/postgres/jobs.rb', line 38

def self.all(connection)
  PgCron::Adapters::Postgres::QueryExecutor.call(
    connection: connection,
    query: JOBS_WITH_DEFINITIONS_QUERY,
    model_class: PgCron::Job
  )
end