Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobret committed Jan 30, 2025
1 parent 69de437 commit a1ea9f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
8 changes: 3 additions & 5 deletions api/src/controllers/elasticsearch/cle/classe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
8 changes: 4 additions & 4 deletions api/src/filterLabel/filterLabelRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
10 changes: 5 additions & 5 deletions api/src/filterLabel/filterLabelService.ts
Original file line number Diff line number Diff line change
@@ -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 };
}

0 comments on commit a1ea9f6

Please sign in to comment.