class Para::Job::Base

Protected Instance Methods

ensure_total_progress() click to toggle source
# File lib/para/job/base.rb, line 35
def ensure_total_progress
  return if @_total_progress

  @_total_progress ||= if respond_to?(:total_progress, true)
    progress.total = total_progress
  else
    progress[:total]
  end
end
progress!() click to toggle source
# File lib/para/job/base.rb, line 20
def progress!
  ensure_total_progress
  progress.increment
end
rescue_exception(exception) click to toggle source
# File lib/para/job/base.rb, line 53
def rescue_exception(exception)
  status.update(status: :failed)

  tag_logger(self.class.name, job_id) do
    ActiveSupport::Notifications.instrument "failed.active_job",
        adapter: self.class.queue_adapter, job: self, exception: exception
  end

  if defined?(ExceptionNotifier)
    ExceptionNotifier.notify_exception(
      exception, data: { job: self.class.name, payload: arguments }
    )
  end

  raise exception
end
save_errors!() click to toggle source
# File lib/para/job/base.rb, line 25
def save_errors!
  status.update(errors: errors.full_messages)
end
store(key, value = nil) click to toggle source
# File lib/para/job/base.rb, line 45
def store(key, value = nil)
  if value
    status.update(key => value)
  else
    status[key]
  end
end
store_job_type() click to toggle source
# File lib/para/job/base.rb, line 16
def store_job_type
  status.update(job_type: self.class.name)
end
total_progress() click to toggle source

Default total progress to nil, making the UI show an animated porgress bar, indicating work is in progress, but not the exact progress

# File lib/para/job/base.rb, line 31
def total_progress
  nil
end