Class: SidekiqBatch::CompletionQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/sidekiq_batch/completion_query.rb

Constant Summary collapse

Policy =
::Sidekiq::Batch::Jobs::FailurePolicy

Class Method Summary collapse

Class Method Details

.sqlString

Returns SQL with one ? placeholder, for the batch id.

Returns:

  • (String)

    SQL with one ? placeholder, for the batch id



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/sidekiq_batch/completion_query.rb', line 9

def sql
  <<~SQL.squish
    UPDATE sidekiq_batches
    SET status       = #{outcome},
        completed_at = NOW(),
        updated_at   = NOW()
    WHERE id = ?
      AND status = #{batch_status("running")}
      AND NOT EXISTS (#{jobs_with(job_status("pending"))})
    RETURNING status
  SQL
end