Skip to content

Commit

Permalink
Merge branch 'master' into feat/tm-1519
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrmr committed Oct 8, 2024
2 parents 4e73a46 + be0ccfb commit aa05e8f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
26 changes: 0 additions & 26 deletions server/src/jobs/hydrate/hydrate-rncp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down Expand Up @@ -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) => {
Expand All @@ -109,7 +103,6 @@ export async function hydrateRNCP() {
{
$set: stripEmptyFields({
...fiche,
opcos: opcosByRNCP[rncp] ?? [],
}),
},
{
Expand All @@ -118,22 +111,3 @@ export async function hydrateRNCP() {
);
});
}

function getOpcosByRNCP(): Record<string, string[]> {
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;
}, {});
}
2 changes: 2 additions & 0 deletions server/src/jobs/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit aa05e8f

Please sign in to comment.