2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-13 16:23:40 +02:00
|
|
|
class ProcessStalledDeclarativeDossierJob < ApplicationJob
|
|
|
|
def perform(dossier)
|
|
|
|
return if dossier.declarative_triggered_at.present?
|
|
|
|
|
|
|
|
case dossier.procedure.declarative_with_state
|
|
|
|
when Procedure.declarative_with_states.fetch(:en_instruction)
|
2023-12-11 13:10:25 +01:00
|
|
|
if !dossier.en_instruction? && dossier.may_passer_automatiquement_en_instruction?
|
2023-06-13 16:23:40 +02:00
|
|
|
dossier.passer_automatiquement_en_instruction!
|
|
|
|
end
|
|
|
|
when Procedure.declarative_with_states.fetch(:accepte)
|
|
|
|
if dossier.may_accepter_automatiquement?
|
|
|
|
dossier.accepter_automatiquement!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def max_attempts
|
|
|
|
3 # this job is enqueued by a cron, so it's better to not retry too much
|
|
|
|
end
|
|
|
|
end
|