Class: Logical::Naf::JobStatuses::Running

Inherits:
Object
  • Object
show all
Defined in:
app/models/logical/naf/job_statuses/running.rb

Class Method Summary collapse

Class Method Details

.all(status = :running, conditions) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/logical/naf/job_statuses/running.rb', line 6

def self.all(status = :running, conditions)
  if status == :queued
    order = "created_at"
    direction = "desc"
  else
    order = "started_at"
    direction = "desc"
  end
  "    (\n      SELECT\n        j.*, null AS \"historical_job_id\"\n      FROM\n        \"\#{::Naf.schema_name}\".\"historical_jobs\" AS j\n      WHERE\n        j.started_at IS NOT NULL AND\n        j.finished_at IS NULL AND\n        j.request_to_terminate = false\n      \#{conditions}\n      ORDER BY\n        \#{order} \#{direction}\n    )\n  SQL\nend\n"