Sha256: dc2954cf829b7182e318a4c386234732967cd1d225665914a483996dfb435a4e

Contents?: true

Size: 641 Bytes

Versions: 11

Compression:

Stored size: 641 Bytes

Contents

class Marty::DelayedJobController < ApplicationController
  # FIXME: We probably don't need this endpoint anymore.
  # It's not used by lambda
  def trigger
    work_off_job if delayed_job.present?
    render json: { status: :ok }, status: :ok
  end

  private

  def delayed_job
    return if params['id'].blank?

    @delayed_job ||= ::Delayed::Job.find_by(id: params['id'])
  end

  def work_off_job
    return if delayed_job.locked_at.present?

    ::Delayed::Job.find_by(id: delayed_job.id)&.update!(
      locked_at: ::Delayed::Job.db_time_now, locked_by: 'Lambda'
    )

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
marty-14.3.0 app/controllers/marty/delayed_job_controller.rb
marty-14.0.0 app/controllers/marty/delayed_job_controller.rb
marty-13.0.2 app/controllers/marty/delayed_job_controller.rb
marty-11.0.0 app/controllers/marty/delayed_job_controller.rb
marty-10.0.3 app/controllers/marty/delayed_job_controller.rb
marty-10.0.2 app/controllers/marty/delayed_job_controller.rb
marty-10.0.0 app/controllers/marty/delayed_job_controller.rb
marty-9.5.1 app/controllers/marty/delayed_job_controller.rb
marty-9.5.0 app/controllers/marty/delayed_job_controller.rb
marty-9.3.3 app/controllers/marty/delayed_job_controller.rb
marty-9.3.2 app/controllers/marty/delayed_job_controller.rb