Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(formation): ajout de la page formation #492

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

gBusato
Copy link
Collaborator

@gBusato gBusato commented Nov 25, 2024

No description provided.

@gBusato gBusato changed the base branch from develop to next November 25, 2024 14:10
@gBusato gBusato force-pushed the feat/page-formation-next branch 4 times, most recently from 9050764 to 89efafc Compare November 26, 2024 09:21
Base automatically changed from next to develop November 26, 2024 17:05
@gBusato gBusato force-pushed the feat/page-formation-next branch 6 times, most recently from d321c47 to 070b585 Compare December 3, 2024 09:34
@gBusato gBusato force-pushed the feat/page-formation-next branch 6 times, most recently from 4aef47b to d3e9bbe Compare December 10, 2024 15:09
Comment on lines 55 to 56
"compareFolders.respectGitIgnore": true,
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dotenv]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[sql]": {
"editor.defaultFormatter": "inferrinizzard.prettier-sql-vscode"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut-être pas nécessaire dans les conf du projet

Comment on lines 27 to 32
.where((w) =>
w.or([
w("formationView.dateFermeture", "is", null),
w("formationView.dateFermeture", ">", sql<Date>`${getDateRentreeScolaire(CURRENT_RENTREE)}`),
])
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux ici utiliser notHistoriqueUnlessCoExistant dans utils/notHistorique.ts

Comment on lines +46 to +48
wb
.selectFrom("formations")
.leftJoin("formationHistorique", "formationHistorique.cfd", "formations.cfd")
.where("formations.dateOuverture", "<=", sql<Date>`${getDateRentreeScolaire(CURRENT_RENTREE)}`)
.where("formationHistorique.ancienCFD", "in", (eb) => eb.selectFrom("formationEtablissement").select("cfd"))
.select("formationHistorique.cfd")
.distinct()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pareil tu peux retrouver certainement des fonctions utils dans utils/notHistorique.ts

Comment on lines +16 to +36
const [nsf, filters, formations] = await Promise.all([
deps.getNsf(codeNsf),
deps.getFilters(),
deps.getFormations({
codeNsf,
codeRegion,
codeDepartement,
codeAcademie,
}),
]);

if (!nsf) {
throw Boom.notFound(`Le domaine de formation avec le code ${codeNsf} est inconnue`);
}

return {
codeNsf,
libelleNsf: nsf.libelleNsf,
filters,
formations,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [nsf, filters, formations] = await Promise.all([
deps.getNsf(codeNsf),
deps.getFilters(),
deps.getFormations({
codeNsf,
codeRegion,
codeDepartement,
codeAcademie,
}),
]);
if (!nsf) {
throw Boom.notFound(`Le domaine de formation avec le code ${codeNsf} est inconnue`);
}
return {
codeNsf,
libelleNsf: nsf.libelleNsf,
filters,
formations,
};
const [{libelleNsf}, filters, formations] = await Promise.all([
deps.getNsf(codeNsf),
deps.getFilters(),
deps.getFormations({
codeNsf,
codeRegion,
codeDepartement,
codeAcademie,
}),
]);
if (!nsf) {
throw Boom.notFound(`Le domaine de formation avec le code ${codeNsf} est inconnue`);
}
return {
codeNsf,
libelleNsf,
filters,
formations,
};

Comment on lines 16 to 37
getKbdClient()
.selectFrom("formationView")
.innerJoin("niveauDiplome", "niveauDiplome.codeNiveauDiplome", "formationView.codeNiveauDiplome")
.leftJoin("formationRome", "formationRome.cfd", "formationView.cfd")
.leftJoin("rome", "rome.codeRome", "formationRome.codeRome")
.select((sb) => [
sb.ref("formationView.cfd").as("cfd"),
sb.ref("niveauDiplome.libelleNiveauDiplome").as("libelleNiveauDiplome"),
sb.ref("formationView.libelleFormation").as("libelleFormation"),
sql<number>`count(distinct ${sb.ref("formationRome.codeRome")})`.as("nb romes total"),
sql<number>`count(distinct case when ${sb.ref(
`rome.${transitionType}`
)} then ${sb.ref("formationRome.codeRome")} end)`.as(`nb romes ${transitionType}`),
])
.groupBy(["formationView.cfd", "niveauDiplome.libelleNiveauDiplome", "formationView.libelleFormation"])
.as("sous_requete")
)
.select((sb) => [sb.ref("sous_requete.cfd").as("cfd")])
.where("sous_requete.cfd", "=", cfd)
.where("nb romes total", ">", 0)
.whereRef("nb romes total", "=", `nb romes ${transitionType}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi whereRef ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pour pouvoir utiliser le "nb romes ${}"

Comment on lines 12 to 36
const formatDispositifs = (dispositifs: string[]) => {
return dispositifs
.filter((libelle) => libelle !== "")
.map((d) => {
return d.replace(/\sen\s/i, " ").replace(/professionnel/i, "PRO");
});
};
const formatSecteur = (secteur: string) => {
switch (secteur) {
case "PU":
return "Public";
case "PR":
return "Privé";
default:
return "";
}
};

const formatDepartement = (departement: string) => {
if (departement.length === 3 && departement.startsWith("0")) {
return departement.substring(1);
}

return departement;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilise peut-être les fonctions utiles de formatage ?

Comment on lines +30 to +34
includeAll: z
.enum(["true", "false"])
.transform((val) => val === "true")
.optional()
.default("false"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh beh, qu'est ce qu'il faut pas faire pour passer un boolean dans une requête....

@gBusato gBusato force-pushed the feat/page-formation-next branch 3 times, most recently from 4bfec82 to c284e59 Compare December 16, 2024 14:33
sb.ref("nsf.codeNsf").as("nsf"),
sb.val("formation").as("type"),
])
.where((w) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On devrait se faire un petit utils de search vu qu'on utilise ce style de requête un peu partout

@@ -0,0 +1,78 @@
import { usePg } from "@tests/pg.test.utils";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

sb.ref("formationView.cfd").as("cfd"),
sb.ref("niveauDiplome.libelleNiveauDiplome").as("libelleNiveauDiplome"),
sb.ref("formationView.libelleFormation").as("libelleFormation"),
sql<number>`count(distinct ${sb.ref("formationRome.codeRome")})`.as("nb romes total"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut-être les nommer en camelCase pour rester consistant dans la nomenclature ?

)} then ${sb.ref("formationRome.codeRome")} end)`.as(`nb romes ${transitionType}`),
])
.groupBy(["formationView.cfd", "niveauDiplome.libelleNiveauDiplome", "formationView.libelleFormation"])
.as("sous_requete")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peu-être être plus précis sur le nommage de cette requête ? Elle ramène quoi ?

])
.$call((qb) => {
if (!codeRegion && !codeDepartement && !codeAcademie) {
qb = qb.where((wb) => wb.and([wb("codeRegion", ">=", "11"), wb("codeRegion", "<=", "93")]));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm je veux bien un commentaire ou un utils qui explicite ce que cette condition fait. Ça garde uniquement les régions IJ ? Ou autre chose ?

.selectFrom("maille_etab")
.innerJoin("indicateurEntree", "indicateurEntree.formationEtablissementId", "maille_etab.id")
.where("cfd", "=", cfd)
.where("rentreeScolaire", ">", "2020")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi 2020 en dur ?

@@ -0,0 +1,55 @@
import { z } from "zod";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si on suit la logique de nomanclature, le fichier devrait être nommé : get.domaine-de-formation.codeNsf.schema.ts

const onExportExcel = async () => {
if (!etablissements.length) return;

trackEvent("domaine-de-formation-etablissements:export-excel");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T'as bien activé les events sur plausible ?

@@ -0,0 +1,192 @@
import { usePlausible } from "next-plausible";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm il me semble qu'on fait différemment avec les exports normalement, il y a un fichier type séparé avec les énums et les colonnes qu'on veut sortir. Peut-être garder cette manière de faire ?

}
chartRef.current.setOption(option, true);
chartRef.current.on("legendselectchanged", (params) => {
//@ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm ?

@gBusato gBusato force-pushed the feat/page-formation-next branch from c284e59 to 4242441 Compare December 17, 2024 08:44
@gBusato gBusato force-pushed the feat/page-formation-next branch from 4242441 to b551bbb Compare December 17, 2024 08:45
@gBusato gBusato merged commit 9c8a03e into develop Dec 17, 2024
4 checks passed
@gBusato gBusato deleted the feat/page-formation-next branch December 17, 2024 08:55
Copy link

🎉 This PR is included in version 0.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants