Skip to content

Commit

Permalink
fix: remarques PR
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasDetre committed Dec 18, 2024
1 parent 6d60b45 commit d12e17f
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { selectTauxDevenirFavorable } from "@/modules/data/utils/tauxDevenirFavo
import { selectTauxInsertion6mois } from "@/modules/data/utils/tauxInsertion6mois";
import { selectTauxPoursuite } from "@/modules/data/utils/tauxPoursuite";
import { selectTauxPressionParFormationEtParRegionDemande } from "@/modules/data/utils/tauxPression";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { isDemandeNotDeleted, isDemandeSelectable } from "@/modules/utils/isDemandeSelectable";
import { isFormationActionPrioritaireDemande } from "@/modules/utils/isFormationActionPrioritaire";
import { isFormationActionPrioritaire } from "@/modules/utils/isFormationActionPrioritaire";
import { getNormalizedSearchArray } from "@/modules/utils/normalizeSearch";
import { cleanNull } from "@/utils/noNull";

Expand Down Expand Up @@ -155,7 +156,11 @@ export const getCorrectionsQuery = async ({
"correction.updatedAt",
"correction.commentaire",
selectPositionQuadrant(eb).as("positionQuadrant"),
isFormationActionPrioritaireDemande(eb).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
isFormationActionPrioritaire({
cfdRef: "demande.cfd",
codeDispositifRef: "demande.codeDispositif",
codeRegionRef: "demande.codeRegion",
}).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
eb.ref("formationView.isTransitionDemographique").as(TypeFormationSpecifiqueEnum["Transition démographique"]),
eb.ref("formationView.isTransitionEcologique").as(TypeFormationSpecifiqueEnum["Transition écologique"]),
eb.ref("formationView.isTransitionNumerique").as(TypeFormationSpecifiqueEnum["Transition numérique"]),
Expand Down Expand Up @@ -304,29 +309,24 @@ export const getCorrectionsQuery = async ({
.where(isDemandeNotDeleted)
.offset(offset)
.limit(limit)
.execute();
.execute()
.then(cleanNull);

const campagnes = await getKbdClient().selectFrom("campagne").selectAll().orderBy("annee desc").execute();
const campagnes = await getKbdClient()
.selectFrom("campagne")
.selectAll()
.orderBy("annee desc")
.execute()
.then(cleanNull);

return {
corrections: corrections.map((correction) =>
cleanNull({
...correction,
createdAt: correction.createdAt?.toISOString(),
updatedAt: correction.updatedAt?.toISOString(),
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!correction[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!correction[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!correction[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!correction[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
),
campagnes: campagnes.map(cleanNull),
corrections: corrections.map((correction) => ({
...correction,
createdAt: correction.createdAt?.toISOString(),
updatedAt: correction.updatedAt?.toISOString(),
formationSpecifique: formatFormationSpecifique(correction),
})),
campagnes,
count: corrections[0]?.count || 0,
};
};
2 changes: 1 addition & 1 deletion server/src/modules/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getFormationRoute } from "./usecases/getFormation/getFormation.route";
import { getFormationCarteEtablissementsRoute } from "./usecases/getFormationCarteEtablissements/getFormationCarteEtablissements.route";
import { getFormationEtablissementsRoutes } from "./usecases/getFormationEtablissements/getFormationEtablissements.routes";
import { getFormationIndicateursRoute } from "./usecases/getFormationIndicateurs/getFormationIndicateurs.route";
import { getFormationsRoute } from "./usecases/getFormations/getFormations.routes";
import { getFormationsRoute } from "./usecases/getFormations/getFormations.route";
import { getFormationsPilotageIntentionsRoute } from "./usecases/getFormationsPilotageIntentions/getFormationsPilotageIntentions.route";
import { getHeaderEtablissementRoute } from "./usecases/getHeaderEtablissement/getHeaderEtablissement.route";
import { getPilotageReformeStatsRoute } from "./usecases/getPilotageReformeStats/getPilotageReformeStats.route";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { sql } from "kysely";
import { TypeFormationSpecifiqueEnum } from "shared/enum/formationSpecifiqueEnum";
import type { Voie } from "shared/enum/voieEnum";

import { isFormationActionPrioritaireDataEtablissement } from "@/modules/utils/isFormationActionPrioritaire";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { isFormationActionPrioritaire } from "@/modules/utils/isFormationActionPrioritaire";
import { cleanNull } from "@/utils/noNull";

import { getBase } from "./base.dep";
Expand All @@ -26,28 +27,22 @@ export const getFormations = async ({ uai }: { uai: string }) =>
"formationView.typeFamille",
"dispositif.libelleDispositif",
"niveauDiplome.libelleNiveauDiplome",
isFormationActionPrioritaireDataEtablissement(eb).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
isFormationActionPrioritaire({
cfdRef: "formationEtablissement.cfd",
codeDispositifRef: "formationEtablissement.codeDispositif",
codeRegionRef: "dataEtablissement.codeRegion",
}).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
eb.ref("formationView.isTransitionDemographique").as(TypeFormationSpecifiqueEnum["Transition démographique"]),
eb.ref("formationView.isTransitionEcologique").as(TypeFormationSpecifiqueEnum["Transition écologique"]),
eb.ref("formationView.isTransitionNumerique").as(TypeFormationSpecifiqueEnum["Transition numérique"]),
])
.$narrowType<{ voie: Voie }>()
.orderBy(["libelleNiveauDiplome asc", "libelleFormation asc", "libelleDispositif"])
.execute()
.then(cleanNull)
.then((formations) =>
formations.map((formation) =>
cleanNull({
...formation,
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!formation[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
)
formations.map((formation) => ({
...formation,
formationSpecifique: formatFormationSpecifique(formation),
}))
);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CURRENT_IJ_MILLESIME } from "shared";
import { TypeFormationSpecifiqueEnum } from "shared/enum/formationSpecifiqueEnum";
import type { Filters } from "shared/routes/schemas/get.panorama.stats.departement.schema";

import { withInsertionReg } from "@/modules/data/utils/tauxInsertion6mois";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { cleanNull } from "@/utils/noNull";

import { getFormationsDepartementBase } from "./getFormationsDepartementBase.dep";
Expand All @@ -22,20 +22,10 @@ export const getFormationsDepartement = async (filters: Filters) =>
null
)
.execute()
.then(cleanNull)
.then((formations) =>
formations.map((formation) =>
cleanNull({
...formation,
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!formation[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
)
formations.map((formation) => ({
...formation,
formationSpecifique: formatFormationSpecifique(formation),
}))
);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { withInsertionReg } from "@/modules/data/utils/tauxInsertion6mois";
import { withPoursuiteReg } from "@/modules/data/utils/tauxPoursuite";
import { selectTauxPressionAgg } from "@/modules/data/utils/tauxPression";
import { selectTauxRemplissageAgg } from "@/modules/data/utils/tauxRemplissage";
import { isFormationActionPrioritaireEtablissement } from "@/modules/utils/isFormationActionPrioritaire";
import { isFormationActionPrioritaire } from "@/modules/utils/isFormationActionPrioritaire";

export const getFormationsDepartementBase = ({
codeDepartement,
Expand Down Expand Up @@ -137,8 +137,12 @@ export const getFormationsDepartementBase = ({
codeDispositifRef: "formationEtablissement.codeDispositif",
codeRegionRef: "etablissement.codeRegion",
}).as("tauxDevenirFavorable"),
isFormationActionPrioritaire({
cfdRef: "formationEtablissement.cfd",
codeDispositifRef: "formationEtablissement.codeDispositif",
codeRegionRef: "etablissement.codeRegion",
}).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
"positionFormationRegionaleQuadrant.positionQuadrant",
isFormationActionPrioritaireEtablissement(eb).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
eb.ref("formationView.isTransitionDemographique").as(TypeFormationSpecifiqueEnum["Transition démographique"]),
eb.ref("formationView.isTransitionEcologique").as(TypeFormationSpecifiqueEnum["Transition écologique"]),
eb.ref("formationView.isTransitionNumerique").as(TypeFormationSpecifiqueEnum["Transition numérique"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CURRENT_IJ_MILLESIME } from "shared";
import { TypeFormationSpecifiqueEnum } from "shared/enum/formationSpecifiqueEnum";
import type { Filters } from "shared/routes/schemas/get.panorama.stats.departement.schema";

import { withTauxDevenirFavorableReg } from "@/modules/data/utils/tauxDevenirFavorable";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { cleanNull } from "@/utils/noNull";

import { getFormationsDepartementBase } from "./getFormationsDepartementBase.dep";
Expand All @@ -22,20 +22,10 @@ export const getTopFlopFormationsDepartement = async (filters: Filters) =>
null
)
.execute()
.then(cleanNull)
.then((formations) =>
formations.map((formation) =>
cleanNull({
...formation,
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!formation[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
)
formations.map((formation) => ({
...formation,
formationSpecifique: formatFormationSpecifique(formation),
}))
);
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CURRENT_IJ_MILLESIME } from "shared";
import { TypeFormationSpecifiqueEnum } from "shared/enum/formationSpecifiqueEnum";
import type { Filters } from "shared/routes/schemas/get.panorama.stats.region.schema";

import { withInsertionReg } from "@/modules/data/utils/tauxInsertion6mois";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { cleanNull } from "@/utils/noNull";

import { getFormationsRegionBase } from "./getFormationsRegionBase.dep";
Expand All @@ -22,20 +22,10 @@ export const getFormationsRegion = async (filters: Filters) =>
null
)
.execute()
.then(cleanNull)
.then((formations) =>
formations.map((formation) =>
cleanNull({
...formation,
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!formation[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
)
formations.map((formation) => ({
...formation,
formationSpecifique: formatFormationSpecifique(formation),
}))
);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { withInsertionReg } from "@/modules/data/utils/tauxInsertion6mois";
import { withPoursuiteReg } from "@/modules/data/utils/tauxPoursuite";
import { selectTauxPressionAgg } from "@/modules/data/utils/tauxPression";
import { selectTauxRemplissageAgg } from "@/modules/data/utils/tauxRemplissage";
import { isFormationActionPrioritaireEtablissement } from "@/modules/utils/isFormationActionPrioritaire";
import { isFormationActionPrioritaire } from "@/modules/utils/isFormationActionPrioritaire";

export const getFormationsRegionBase = ({
codeRegion,
Expand Down Expand Up @@ -135,7 +135,11 @@ export const getFormationsRegionBase = ({
codeRegionRef: "etablissement.codeRegion",
}).as("tauxDevenirFavorable"),
"positionFormationRegionaleQuadrant.positionQuadrant",
isFormationActionPrioritaireEtablissement(eb).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
isFormationActionPrioritaire({
cfdRef: "formationEtablissement.cfd",
codeDispositifRef: "formationEtablissement.codeDispositif",
codeRegionRef: "etablissement.codeRegion",
}).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
eb.ref("formationView.isTransitionDemographique").as(TypeFormationSpecifiqueEnum["Transition démographique"]),
eb.ref("formationView.isTransitionEcologique").as(TypeFormationSpecifiqueEnum["Transition écologique"]),
eb.ref("formationView.isTransitionNumerique").as(TypeFormationSpecifiqueEnum["Transition numérique"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CURRENT_IJ_MILLESIME } from "shared";
import { TypeFormationSpecifiqueEnum } from "shared/enum/formationSpecifiqueEnum";
import type { Filters } from "shared/routes/schemas/get.panorama.stats.region.schema";

import { withTauxDevenirFavorableReg } from "@/modules/data/utils/tauxDevenirFavorable";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { cleanNull } from "@/utils/noNull";

import { getFormationsRegionBase } from "./getFormationsRegionBase.dep";
Expand All @@ -22,20 +22,10 @@ export const getTopFlopFormationsRegion = async (filters: Filters) =>
null
)
.execute()
.then(cleanNull)
.then((formations) =>
formations.map((formation) =>
cleanNull({
...formation,
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!formation[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!formation[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
)
formations.map((formation) => ({
...formation,
formationSpecifique: formatFormationSpecifique(formation),
}))
);
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import {
countDifferenceCapaciteScolaire,
countDifferenceCapaciteScolaireColoree,
} from "@/modules/utils/countCapacite";
import { formatFormationSpecifique } from "@/modules/utils/formatFormationSpecifique";
import { isDemandeNotDeleted } from "@/modules/utils/isDemandeSelectable";
import { isFormationActionPrioritaireDemande } from "@/modules/utils/isFormationActionPrioritaire";
import { isFormationActionPrioritaire } from "@/modules/utils/isFormationActionPrioritaire";
import { isRestitutionIntentionVisible } from "@/modules/utils/isRestitutionIntentionVisible";
import { getNormalizedSearchArray } from "@/modules/utils/normalizeSearch";
import { cleanNull } from "@/utils/noNull";
Expand Down Expand Up @@ -126,7 +127,11 @@ export const getDemandesRestitutionIntentionsQuery = async ({
rentreeScolaire: CURRENT_RENTREE,
}).as("nbEtablissement"),
selectPositionQuadrant(eb).as("positionQuadrant"),
isFormationActionPrioritaireDemande(eb).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
isFormationActionPrioritaire({
cfdRef: "formationEtablissement.cfd",
codeDispositifRef: "formationEtablissement.codeDispositif",
codeRegionRef: "etablissement.codeRegion",
}).as(TypeFormationSpecifiqueEnum["Action prioritaire"]),
eb.ref("formationView.isTransitionDemographique").as(TypeFormationSpecifiqueEnum["Transition démographique"]),
eb.ref("formationView.isTransitionEcologique").as(TypeFormationSpecifiqueEnum["Transition écologique"]),
eb.ref("formationView.isTransitionNumerique").as(TypeFormationSpecifiqueEnum["Transition numérique"]),
Expand Down Expand Up @@ -275,27 +280,17 @@ export const getDemandesRestitutionIntentionsQuery = async ({
.where(isRestitutionIntentionVisible({ user }))
.offset(offset)
.limit(limit)
.execute();
.execute()
.then(cleanNull);

return {
demandes: demandes.map((demande) =>
cleanNull({
...demande,
statut: castDemandeStatutWithoutSupprimee(demande.statut),
createdAt: demande.createdAt?.toISOString(),
updatedAt: demande.updatedAt?.toISOString(),
formationSpecifique: {
[TypeFormationSpecifiqueEnum["Action prioritaire"]]:
!!demande[TypeFormationSpecifiqueEnum["Action prioritaire"]],
[TypeFormationSpecifiqueEnum["Transition démographique"]]:
!!demande[TypeFormationSpecifiqueEnum["Transition démographique"]],
[TypeFormationSpecifiqueEnum["Transition écologique"]]:
!!demande[TypeFormationSpecifiqueEnum["Transition écologique"]],
[TypeFormationSpecifiqueEnum["Transition numérique"]]:
!!demande[TypeFormationSpecifiqueEnum["Transition numérique"]],
},
})
),
demandes: demandes.map((demande) => ({
...demande,
statut: castDemandeStatutWithoutSupprimee(demande.statut),
createdAt: demande.createdAt?.toISOString(),
updatedAt: demande.updatedAt?.toISOString(),
formationSpecifique: formatFormationSpecifique(demande),
})),
count: parseInt(demandes[0]?.count) || 0,
};
};
Loading

0 comments on commit d12e17f

Please sign in to comment.