From 9d46514467800780ec03f9c36821f26eeb076bfe Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 23 Sep 2024 21:15:14 +0200 Subject: [PATCH] fix(resolve_pending_correction): role back pending_correction for champs without external_id --- ...ion_for_dossier_with_invalid_commune_external_id_task.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/tasks/maintenance/resolve_pending_correction_for_dossier_with_invalid_commune_external_id_task.rb b/app/tasks/maintenance/resolve_pending_correction_for_dossier_with_invalid_commune_external_id_task.rb index a48c2d978..badfa4c43 100644 --- a/app/tasks/maintenance/resolve_pending_correction_for_dossier_with_invalid_commune_external_id_task.rb +++ b/app/tasks/maintenance/resolve_pending_correction_for_dossier_with_invalid_commune_external_id_task.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module Maintenance + # this maintenance task should be run due to app/tasks/maintenance/fix_champs_commune_having_value_but_not_external_id_task.rb + # if you have not ran app/tasks/maintenance/fix_champs_commune_having_value_but_not_external_id_task.rb, this task is not required class ResolvePendingCorrectionForDossierWithInvalidCommuneExternalIdTask < MaintenanceTasks::Task DEFAULT_INSTRUCTEUR_EMAIL = ENV.fetch('DEFAULT_INSTRUCTEUR_EMAIL') { CONTACT_EMAIL } @@ -14,6 +16,8 @@ module Maintenance penultimate_traitement, last_traitement = *dossier_correction.dossier.traitements.last(2) dossier_correction.resolve! + next if penultimate_traitement.nil? || last_traitement.nil? + if last_traitement_by_us?(last_traitement) && last_transition_to_en_construction?(last_traitement, penultimate_traitement) dossier_correction.dossier.passer_en_instruction(instructeur: current_instructeur) if dossier_correction.dossier.validate(:champs_public_value) end @@ -33,7 +37,7 @@ module Maintenance end def last_traitement_by_us?(traitement) - traitement.instructeur_email == DEFAULT_INSTRUCTEUR_EMAIL + traitement&.instructeur_email == DEFAULT_INSTRUCTEUR_EMAIL end def last_transition_to_en_construction?(last_traitement, penultimate_traitement)