refactor(declarative): process dossier in job isolation
This commit is contained in:
parent
92bdab3de4
commit
17f5fb4a51
5 changed files with 160 additions and 134 deletions
20
app/jobs/process_stalled_declarative_dossier_job.rb
Normal file
20
app/jobs/process_stalled_declarative_dossier_job.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
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)
|
||||
if !dossier.en_instruction?
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue