From d9aeb65ec5715d5a86159fd3e3fab44ff4f8b187 Mon Sep 17 00:00:00 2001 From: Ananda Date: Tue, 12 Nov 2024 14:10:19 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20du=20choix=20du=20mill=C3=A9sim?= =?UTF-8?q?e=20dans=20les=20jobs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/cli.js | 8 ++++++-- server/src/jobs/stats/computeContinuumStats.js | 4 +++- server/src/jobs/stats/importFormationsSupStats.js | 1 + server/tests/jobs/stats/importFormationsSupStats-test.js | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/cli.js b/server/src/cli.js index 14d613b2..afabc37d 100644 --- a/server/src/cli.js +++ b/server/src/cli.js @@ -118,8 +118,12 @@ cli .command("computeContinuumStats") .description("Calcule les données statistiques manquantes pour les anciens/nouveaux diplomes") .argument("[stats]", "Le nom des stats à importer (formations,certifications,regionales)", asArray) - .action((stats) => { - runScript(() => computeContinuumStats({ stats })); + .option( + "--millesime [millesime]", + "Spécifie un millésime à importer (attention les millésimes nationales et formations/regionales sont différents" + ) + .action((stats, options) => { + runScript(() => computeContinuumStats({ stats, millesime: options.millesime })); }); cli diff --git a/server/src/jobs/stats/computeContinuumStats.js b/server/src/jobs/stats/computeContinuumStats.js index dd5e1124..99592adc 100644 --- a/server/src/jobs/stats/computeContinuumStats.js +++ b/server/src/jobs/stats/computeContinuumStats.js @@ -203,6 +203,8 @@ export async function computeContinuumStats(options = {}) { let stats = options.stats || ["certifications", "regionales", "formations"]; const result = { total: 0, created: 0, updated: 0, failed: 0 }; + const millesime = options.millesime || null; + function handleError(e, context = {}) { logger.error({ err: e, ...context }, `Impossible de calculer les données pour les anciens/nouveaux diplomes`); result.failed++; @@ -211,7 +213,7 @@ export async function computeContinuumStats(options = {}) { await oleoduc( mergeStreams(stats.map(streamStats)), - filterData(({ data }) => data.donnee_source.type === "self"), + filterData(({ data }) => data.donnee_source.type === "self" && (!millesime || data.millesime === millesime)), transformData(async ({ data, statName }) => { const query = { ...getQueryForStats({ data, statName, millesime: data.millesime }) }; diff --git a/server/src/jobs/stats/importFormationsSupStats.js b/server/src/jobs/stats/importFormationsSupStats.js index e471b68a..58b4362f 100644 --- a/server/src/jobs/stats/importFormationsSupStats.js +++ b/server/src/jobs/stats/importFormationsSupStats.js @@ -106,6 +106,7 @@ export async function importFormationsSupStats(options = {}) { code_certification: formationStats.diplome, type: "self", }, + libelle_etablissement: formationStats.uo_lib, "_meta.insersup": { etablissement_libelle: formationStats.uo_lib, etablissement_actuel_libelle: formationStats.uo_lib_actuel, diff --git a/server/tests/jobs/stats/importFormationsSupStats-test.js b/server/tests/jobs/stats/importFormationsSupStats-test.js index 0d80e974..37f16aff 100644 --- a/server/tests/jobs/stats/importFormationsSupStats-test.js +++ b/server/tests/jobs/stats/importFormationsSupStats-test.js @@ -55,6 +55,7 @@ describe("importFormationsSupStats", () => { code_certification: "2500200", code_certification_type: "sise", libelle: "METIERS DE L'ENSEIGNEMENT", + libelle_etablissement: "Université Côte d'Azur", millesime: "2020_2021", filiere: "superieur", date_fermeture: new Date("2023-01-01T00:00:00.000Z"),