Skip to content

Commit

Permalink
fix: script de mise a jour des status et ajout du job (#3653)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrmr authored Apr 25, 2024
1 parent 0dc8a1b commit f85c02a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 6 additions & 0 deletions server/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ program
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("tmp:effectifs:update_computed_statut"));

program
.command("hydrate:effectifs:update_computed_statut")
.description("Remplissage du champ effectifs._computed avec les types des effectifs")
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("hydrate:effectifs:update_computed_statut"));

program
.command("hydrate:effectifs-formation-niveaux")
.description("Remplissage du champ niveau des formations des effectifs")
Expand Down
11 changes: 4 additions & 7 deletions server/src/common/actions/effectifs.statut.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,10 @@ function determineNewStatutFromHistorique(
];

sortedHistoriqueStatut.forEach((statut) => {
const statutYear = new Date(statut.date_statut).getFullYear();
if (statutYear >= startYear && statutYear <= endYear) {
parcours.push({
valeur: mapValeurStatutToStatutApprenant(statut.valeur_statut),
date: new Date(statut.date_statut),
});
}
parcours.push({
valeur: mapValeurStatutToStatutApprenant(statut.valeur_statut),
date: new Date(statut.date_statut),
});
});

return parcours;
Expand Down
9 changes: 7 additions & 2 deletions server/src/jobs/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function setupJobProcessor() {
"Mettre à jour les statuts d'effectifs le 1er de chaque mois à 00h45": {
cron_string: "45 0 1 * *",
handler: async () => {
await addJob({ name: "hydrate:effectifs:update_computed_statut", queued: true });
await addJob({ name: "hydrate:effectifs:update_computed_statut_month", queued: true });
return 0;
},
},
Expand Down Expand Up @@ -212,6 +212,11 @@ export async function setupJobProcessor() {
return hydrateEffectifsComputedTypes();
},
},
"hydrate:effectifs:update_computed_statut": {
handler: async () => {
return await addJob({ name: "tmp:effectifs:update_computed_statut", queued: true });
},
},
"hydrate:effectifs-formation-niveaux": {
handler: async () => {
return hydrateEffectifsFormationsNiveaux();
Expand Down Expand Up @@ -262,7 +267,7 @@ export async function setupJobProcessor() {
return hydrateDeca(job.payload as any);
},
},
"hydrate:effectifs:update_computed_statut": {
"hydrate:effectifs:update_computed_statut_month": {
handler: async () => {
return hydrateEffectifsComputedTypes({
query: { annee_scolaire: { $in: getAnneesScolaireListFromDate(new Date()) } },
Expand Down

0 comments on commit f85c02a

Please sign in to comment.