From 0dc8a1b647eb56fbf11d308ee11aa05b5ab43899 Mon Sep 17 00:00:00 2001 From: Nicolas KREMER Date: Thu, 25 Apr 2024 09:59:37 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20script=20de=20mise=20=C3=A0=20jour=20des?= =?UTF-8?q?=20status=20=C3=A0=20partir=20de=20l=20historique=5Fstatut=20(#?= =?UTF-8?q?3652)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/common/actions/effectifs.statut.actions.ts | 8 +++++--- .../20240424153421-effectifs-computed-statuts.ts | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 server/src/db/migrations/20240424153421-effectifs-computed-statuts.ts diff --git a/server/src/common/actions/effectifs.statut.actions.ts b/server/src/common/actions/effectifs.statut.actions.ts index 4a612c877..97db3b72c 100644 --- a/server/src/common/actions/effectifs.statut.actions.ts +++ b/server/src/common/actions/effectifs.statut.actions.ts @@ -227,10 +227,12 @@ function determineNewStatutFromHistorique( sortedHistoriqueStatut.shift(); } - let earliestStatutDate = new Date(sortedHistoriqueStatut[0].date_statut); + if (sortedHistoriqueStatut.length > 0 && sortedHistoriqueStatut[0].date_statut) { + let earliestStatutDate = new Date(sortedHistoriqueStatut[0].date_statut); - if (earliestStatutDate < inscriptionDate) { - inscriptionDate = earliestStatutDate; + if (earliestStatutDate < inscriptionDate) { + inscriptionDate = earliestStatutDate; + } } const parcours: { valeur: StatutApprenant; date: Date }[] = [ diff --git a/server/src/db/migrations/20240424153421-effectifs-computed-statuts.ts b/server/src/db/migrations/20240424153421-effectifs-computed-statuts.ts new file mode 100644 index 000000000..b480a6384 --- /dev/null +++ b/server/src/db/migrations/20240424153421-effectifs-computed-statuts.ts @@ -0,0 +1,5 @@ +import { addJob } from "job-processor"; + +export const up = async () => { + await addJob({ name: "tmp:effectifs:update_computed_statut", queued: true }); +};