From a1ea9f620c14e35adb91e3a6ecd87871a7ac87fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Bret=C3=A9cher?= Date: Thu, 30 Jan 2025 12:13:09 +0100 Subject: [PATCH] up --- api/src/controllers/elasticsearch/cle/classe.js | 8 +++----- api/src/filterLabel/filterLabelRepository.ts | 8 ++++---- api/src/filterLabel/filterLabelService.ts | 10 +++++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/api/src/controllers/elasticsearch/cle/classe.js b/api/src/controllers/elasticsearch/cle/classe.js index 5daf3adfa1..6acac1722c 100644 --- a/api/src/controllers/elasticsearch/cle/classe.js +++ b/api/src/controllers/elasticsearch/cle/classe.js @@ -65,11 +65,9 @@ router.post("/:action(search|export)", passport.authenticate(["referent"], { ses if (req.params.action === "export") { let response = await allRecords("classe", hitsRequestBody.query, esClient, exportFields); - if (req.query?.type === "export-des-classes") { - response = await populateWithEtablissementInfo(response); - response = await populateWithYoungsInfo(response); - response = await populateWithAllReferentsInfo(response); - } + response = await populateWithEtablissementInfo(response); + response = await populateWithYoungsInfo(response); + response = await populateWithAllReferentsInfo(response); if (req.query?.type === "schema-de-repartition") { if (![ROLES.ADMIN, ROLES.REFERENT_REGION, ROLES.TRANSPORTER].includes(user.role)) return res.status(403).send({ ok: false, code: ERRORS.OPERATION_UNAUTHORIZED }); diff --git a/api/src/filterLabel/filterLabelRepository.ts b/api/src/filterLabel/filterLabelRepository.ts index d35638a581..ff99e3ecb9 100644 --- a/api/src/filterLabel/filterLabelRepository.ts +++ b/api/src/filterLabel/filterLabelRepository.ts @@ -7,23 +7,23 @@ function formatLabel(data, key: string) { }, {}); } -export async function getBus() { +export async function getLigneLabel() { const data = await LigneBusModel.find({}, { busId: 1 }); return formatLabel(data, "busId"); } -export async function getClasses() { +export async function getClasseLabel() { // Pourquoi ça renvoit les patches ça ? const data = await ClasseModel.find({}, { uniqueKeyAndId: 1 }); return formatLabel(data, "uniqueKeyAndId"); } -export async function getEtablissements() { +export async function getEtablissementLabel() { const data = await EtablissementModel.find({}, { name: 1 }); return formatLabel(data, "name"); } -export async function getSessions() { +export async function getSessionLabel() { const data = await SessionPhase1Model.find({}, { codeCentre: 1 }); return formatLabel(data, "codeCentre"); } diff --git a/api/src/filterLabel/filterLabelService.ts b/api/src/filterLabel/filterLabelService.ts index c0a71fbd1c..fbb453a756 100644 --- a/api/src/filterLabel/filterLabelService.ts +++ b/api/src/filterLabel/filterLabelService.ts @@ -1,11 +1,11 @@ -import { getBus, getClasses, getEtablissements, getSessions } from "./filterLabelRepository"; +import { getClasseLabel, getEtablissementLabel, getLigneLabel, getSessionLabel } from "./filterLabelRepository"; export const listTypes = { INSCRIPTION: "inscription", VOLONTAIRES: "volontaires" }; export async function getLabelVolontaires() { - const sessions = await getSessions(); - const bus = await getBus(); - const classes = await getClasses(); - const etablissements = await getEtablissements(); + const sessions = await getSessionLabel(); + const bus = await getLigneLabel(); + const classes = await getClasseLabel(); + const etablissements = await getEtablissementLabel(); return { sessions, bus, classes, etablissements }; }