fix(auto_archive_procedure_job): AutoArchiveProcedureJob may take longer than its cron delay [everyminutes], when it takes more than one minute, we re-enqueue the same mails
This commit is contained in:
parent
4b740f8f29
commit
babdf9536f
4 changed files with 62 additions and 19 deletions
16
app/jobs/auto_archive_procedure_dossiers_job.rb
Normal file
16
app/jobs/auto_archive_procedure_dossiers_job.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AutoArchiveProcedureDossiersJob < ApplicationJob
|
||||
def perform(procedure)
|
||||
procedure
|
||||
.dossiers
|
||||
.state_en_construction
|
||||
.find_each do |d|
|
||||
begin
|
||||
d.passer_automatiquement_en_instruction!
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,18 +2,15 @@
|
|||
|
||||
class Cron::AutoArchiveProcedureJob < Cron::CronJob
|
||||
self.schedule_expression = "every 1 minute"
|
||||
queue_as :critical
|
||||
|
||||
def perform(*args)
|
||||
procedures_to_close.each do |procedure|
|
||||
# A buggy procedure should NEVER prevent the closing of another procedure
|
||||
# we therefore exceptionally add a `begin resue` block.
|
||||
begin
|
||||
procedure
|
||||
.dossiers
|
||||
.state_en_construction
|
||||
.find_each(&:passer_automatiquement_en_instruction!)
|
||||
|
||||
procedure.close!
|
||||
AutoArchiveProcedureDossiersJob.perform_later(procedure)
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e, extra: { procedure_id: procedure.id })
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue