Skip to content

Commit

Permalink
feat: ajout du choix du millésime dans les jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ST0R committed Nov 12, 2024
1 parent 706dbf7 commit d9aeb65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions server/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion server/src/jobs/stats/computeContinuumStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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 }) };

Expand Down
1 change: 1 addition & 0 deletions server/src/jobs/stats/importFormationsSupStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions server/tests/jobs/stats/importFormationsSupStats-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit d9aeb65

Please sign in to comment.