Class: Jobs::WatchChildJobs

Inherits:
Que::Job show all
Defined in:
lib/jobs/watch_child_jobs.rb

Instance Method Summary collapse

Methods included from Que::BackgroundJobLogger

#_run

Methods included from Que::SetApplicationNameWhenJobRuns

#_run, #get_application_name_when_job_runs, #set_application_name_when_job_runs

Instance Method Details

#run(options) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/jobs/watch_child_jobs.rb', line 3

def run(options)
  unless QueJob.where(parent_job_id: options[:job_id]).count > 0
    QueJobStatus.where(job_id: options[:job_id]).update_all(finished_at: Time.now, status: 'finished')
    return
  end

  self.class.enqueue(options.merge(run_at: Time.current + 1.second))
end