From 5b23fcb1f29ca7eb5476bbae50255ecf6d91c8f2 Mon Sep 17 00:00:00 2001 From: Paul Gaucher Date: Tue, 8 Oct 2024 10:04:55 +0200 Subject: [PATCH] fix: ajout de la maj des rncp dans le daily --- server/src/jobs/hydrate/hydrate-rncp.ts | 26 ------------------------- server/src/jobs/jobs.ts | 2 ++ 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/server/src/jobs/hydrate/hydrate-rncp.ts b/server/src/jobs/hydrate/hydrate-rncp.ts index 953634b52..eced66ba4 100644 --- a/server/src/jobs/hydrate/hydrate-rncp.ts +++ b/server/src/jobs/hydrate/hydrate-rncp.ts @@ -11,12 +11,8 @@ import { IRncp } from "shared/models/data/rncp.model"; import parentLogger from "@/common/logger"; import { rncpDb } from "@/common/model/collections"; -import { readJsonFromCsvFile } from "@/common/utils/fileUtils"; -import { getStaticFilePath } from "@/common/utils/getStaticFilePath"; import { stripEmptyFields } from "@/common/utils/miscUtils"; -import { OPCOS } from "./hydrate-organismes-opcos"; - const logger = parentLogger.child({ module: "job:hydrate:rncp", }); @@ -94,8 +90,6 @@ export async function hydrateRNCP() { logger.info({ count: fichesRNCP.length }, "import des fiches rncp"); - const opcosByRNCP = getOpcosByRNCP(); - await PromisePool.for(fichesRNCP) .withConcurrency(50) .handleError(async (error) => { @@ -109,7 +103,6 @@ export async function hydrateRNCP() { { $set: stripEmptyFields({ ...fiche, - opcos: opcosByRNCP[rncp] ?? [], }), }, { @@ -118,22 +111,3 @@ export async function hydrateRNCP() { ); }); } - -function getOpcosByRNCP(): Record { - return OPCOS.reduce((opcosByRNCP, opco) => { - const codes_rncp = ( - readJsonFromCsvFile(getStaticFilePath(`opcos/${opco}.csv`), ";") as { code_rncp: string }[] - ).map((row) => row.code_rncp); - logger.info({ opco, count: codes_rncp.length }, "rncp chargés"); - - codes_rncp.forEach((rncp) => { - let existingItem = opcosByRNCP[rncp]; - if (!existingItem) { - existingItem = opcosByRNCP[rncp] = []; - } - existingItem.push(opco); - }); - - return opcosByRNCP; - }, {}); -} diff --git a/server/src/jobs/jobs.ts b/server/src/jobs/jobs.ts index 43b6f7262..f7e4f825e 100644 --- a/server/src/jobs/jobs.ts +++ b/server/src/jobs/jobs.ts @@ -126,6 +126,8 @@ const dailyJobs = async () => { }); await addJob({ name: "fiabilisation:effectifs:transform-rupturants-en-abandons-depuis", queued: true }); + await addJob({ name: "hydrate:rncp", queued: true }); + return 0; };