Class: CompletionKit::RunCompletionCheckJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/completion_kit/run_completion_check_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(run_id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/jobs/completion_kit/run_completion_check_job.rb', line 9

def perform(run_id)
  run = Run.find_by(id: run_id)
  return unless run
  return unless run.status == "running"
  # A run that has been claimed but whose rows are still being inserted by
  # StartRunJob has no outstanding work yet, and would otherwise complete
  # itself with zero responses.
  return if run.progress_total.zero?
  return unless run.outstanding_work_zero?

  run.mark_completed!
end