class Lanes::Job
A job in lanes is identical to a ActiveJob::Base job, except it records it's status using the Jobba::Status mixin module
Public Class Methods
api_status_message(job, message="Job started")
click to toggle source
# File lib/lanes/job.rb, line 69 def self.api_status_message(job, message="Job started") return { success: true, message: message, data: { job: Lanes::Job.status_for_id(job.job_id) } } end
status_for_id(id)
click to toggle source
# File lib/lanes/job.rb, line 53 def self.status_for_id(id) status = Jobba.find(id) return nil unless status { id: status.id, job_name: status.job_name, progress: status.progress, attempt: status.attempt, state: status.state.name, recorded_at: status.recorded_at, queued_at: status.queued_at, errors: status.errors, data: status.data } end
Public Instance Methods
deliver_progress_to_clients()
click to toggle source
# File lib/lanes/job.rb, line 40 def deliver_progress_to_clients ::Lanes::API::PubSub.publish( "/lanes/job-statuses/#{job_id}", update: Job.status_for_id(job_id) ) end
save_progress(output, progress=1.0)
click to toggle source
# File lib/lanes/job.rb, line 47 def save_progress(output, progress=1.0) job_status.set_progress(progress) job_status.save(output: output) deliver_progress_to_clients end