Sha256: 37e85282cf9b1a8099eeef09abfb3c584e663ac97558221accf6a6b8a4d85c52

Contents?: true

Size: 557 Bytes

Versions: 7

Compression:

Stored size: 557 Bytes

Contents

class Marty::DelayedJobController < ActionController::Base
  def trigger
    work_off_job if delayed_job.present?
    render json: { status: :ok }, status: :ok
  end

  private

  def delayed_job
    return unless params['id'].present?
    @delayed_job ||= ::Delayed::Job.find_by(id: params['id'])
  end

  def work_off_job
    return if delayed_job.locked_at.present?

    ::Delayed::Job.where(id: delayed_job.id).
      update_all(locked_at: ::Delayed::Job.db_time_now, locked_by: 'Lambda')

    w = ::Delayed::Worker.new
    w.run(delayed_job)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
marty-2.5.2 app/controllers/marty/delayed_job_controller.rb
marty-2.5.1 app/controllers/marty/delayed_job_controller.rb
marty-2.5.0 app/controllers/marty/delayed_job_controller.rb
marty-2.4.9 app/controllers/marty/delayed_job_controller.rb
marty-2.4.8 app/controllers/marty/delayed_job_controller.rb
marty-2.4.7 app/controllers/marty/delayed_job_controller.rb
marty-2.4.6 app/controllers/marty/delayed_job_controller.rb