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

Fix position quadrant #142

Merged
merged 31 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
86521f3
feat: quadrant remplace cadran
LucasDetre Nov 9, 2023
4fc1ef3
fix: affichage détail formation
LucasDetre Nov 9, 2023
3fd5295
feat: ajout tri tableau quadrant et refacto nommage
LucasDetre Nov 9, 2023
cbd77c9
fix: tooltips
LucasDetre Nov 9, 2023
0252791
fix: divers panorama + refacto
LucasDetre Nov 10, 2023
cffb264
fix: position quadrant et niveau diplome
LucasDetre Nov 13, 2023
0f831c5
feat: design
LucasDetre Nov 13, 2023
6cc258a
fix: fix
LucasDetre Nov 14, 2023
f82da93
refacto: colors du thème DSFR
LucasDetre Nov 15, 2023
d357c14
fix: regressions panorama
LucasDetre Nov 15, 2023
275c4ec
fix: ajout de loaders
LucasDetre Nov 15, 2023
c169592
fix: fix
LucasDetre Nov 15, 2023
13060d3
feat: affichage du continuum sur le tableau quadrant
LucasDetre Nov 15, 2023
85a6542
fix: gestion des demandes uniques par libellé FCIL
LucasDetre Nov 15, 2023
b368429
feat: ajout du CFD dans les exports quadrant
LucasDetre Nov 15, 2023
094fe22
fix: passage au calcul de la position quadrant en ts
LucasDetre Nov 16, 2023
4eb3cb5
fix: fix
LucasDetre Nov 16, 2023
707c420
fix: nombre formations panorama + fix divers
LucasDetre Nov 21, 2023
719eebf
Merge branch 'develop' of github.com:mission-apprentissage/tjp-pilota…
LucasDetre Nov 21, 2023
91fbb98
chore: prettier
LucasDetre Nov 21, 2023
f20b13f
feat: suppression de l'affichage des données hors périmètre IJ
LucasDetre Nov 21, 2023
b996d70
fix: taux remplissage pour un département
LucasDetre Nov 21, 2023
4a90162
ci: typecheck
Nov 22, 2023
e72f9d6
feat: ajustement des arrondis des taux régionaux
LucasDetre Nov 22, 2023
1b86391
feat: ajout tooltip taux de pression pilotage transfo
LucasDetre Nov 22, 2023
6e1d1a4
feat: changement banner orion
LucasDetre Nov 22, 2023
a138ad0
fix: type
LucasDetre Nov 22, 2023
b5e0730
fix: getFormations
Nov 22, 2023
f845d7c
fix: arrondis
LucasDetre Nov 23, 2023
2531423
Merge branch 'fix-position-quadrant' of github.com:mission-apprentiss…
LucasDetre Nov 23, 2023
2072469
Merge branch 'develop' of github.com:mission-apprentissage/tjp-pilota…
LucasDetre Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ clean:
typecheck:
yarn --cwd server typecheck && yarn --cwd ui typecheck

prettier_fix:
yarn prettier:fix

test:
yarn --cwd server test

Expand Down
2 changes: 1 addition & 1 deletion server/src/modules/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDataForPanoramaDepartementRoute } from "./usecases/getDataForPanoram
import { getDataForPanoramaRegionRoute } from "./usecases/getDataForPanoramaRegion/getDataForPanoramaRegion.route";
import { getDepartementRoute } from "./usecases/getDepartement/getDepartement.route";
import { getDepartementsRoute } from "./usecases/getDepartements/getDepartements.route";
import { getEtablissementRoute } from "./usecases/getEtablissement/etablissements.routes";
import { getEtablissementRoute } from "./usecases/getEtablissement/getEtablissement.route";
import { getEtablissementsRoutes } from "./usecases/getEtablissements/getEtablissements.routes";
import { getFormationsRoute } from "./usecases/getFormations/formations.routes";
import { getFormationsTransformationsRoute } from "./usecases/getFormationsTransformationStats/getFormationsTransformations.route";
Expand Down
184 changes: 184 additions & 0 deletions server/src/modules/data/queries/getStatsSortie/getStatsSortie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import { kdb } from "../../../../db/db";
import { notHistoriqueIndicateurRegionSortie } from "../../utils/notHistorique";
import { selectTauxInsertion6moisAgg } from "../../utils/tauxInsertion6mois";
import { selectTauxPoursuiteAgg } from "../../utils/tauxPoursuite";

const getStatsSortieBase = ({
codeRegion,
codeDepartement,
codeNiveauDiplome,
millesimeSortie = "2020_2021",
}: {
codeRegion?: string | string[];
codeDepartement?: string | string[];
millesimeSortie?: string;
codeNiveauDiplome?: string[];
}) => {
const statsSortie = kdb
.selectFrom("indicateurRegionSortie")
.innerJoin(
"formation",
"formation.codeFormationDiplome",
"indicateurRegionSortie.cfd"
)
.where((w) => {
if (!codeRegion) return w.val(true);
if (Array.isArray(codeRegion))
return w("indicateurRegionSortie.codeRegion", "in", codeRegion);
return w("indicateurRegionSortie.codeRegion", "=", codeRegion);
})
.$call((q) => {
if (!codeDepartement?.length) return q;
if (Array.isArray(codeDepartement))
return q
.innerJoin(
"departement",
"departement.codeRegion",
"indicateurRegionSortie.codeRegion"
)
.where("departement.codeDepartement", "in", codeDepartement);
return q
.innerJoin(
"departement",
"departement.codeRegion",
"indicateurRegionSortie.codeRegion"
)
.where("departement.codeDepartement", "=", codeDepartement);
})
.$call((q) => {
if (!codeNiveauDiplome?.length) return q;
return q.where("formation.codeNiveauDiplome", "in", codeNiveauDiplome);
})
.where("indicateurRegionSortie.millesimeSortie", "=", millesimeSortie)
.where(notHistoriqueIndicateurRegionSortie)
.select([
selectTauxInsertion6moisAgg("indicateurRegionSortie").as("tauxInsertion"),
selectTauxPoursuiteAgg("indicateurRegionSortie").as("tauxPoursuite"),
]);

return statsSortie;
};

export const getStatsSortieParNiveauDiplome = async ({
codeRegion,
codeNiveauDiplome,
millesimeSortie = "2020_2021",
}: {
codeRegion?: string[];
millesimeSortie?: string;
codeNiveauDiplome?: string[];
}) => {
const statsSortie = await getStatsSortieBase({
codeRegion,
codeNiveauDiplome,
millesimeSortie,
})
.select(["formation.codeNiveauDiplome"])
.groupBy("formation.codeNiveauDiplome")
.execute();

return statsSortie.reduce(
(acc, cur) => {
acc[cur.codeNiveauDiplome] = {
tauxInsertion: cur.tauxInsertion,
tauxPoursuite: cur.tauxPoursuite,
};
return acc;
},
{} as Record<string, { tauxInsertion: number; tauxPoursuite: number }>
);
};

export const getStatsSortieParRegionsEtNiveauDiplome = async ({
codeRegion,
codeNiveauDiplome,
millesimeSortie = "2020_2021",
}: {
codeRegion?: string | string[];
codeNiveauDiplome?: string[];
millesimeSortie?: string;
}) => {
const statsSortie = await getStatsSortieBase({
codeRegion,
codeNiveauDiplome,
millesimeSortie,
})
.select([
"indicateurRegionSortie.codeRegion",
"formation.codeNiveauDiplome",
])
.groupBy([
"indicateurRegionSortie.codeRegion",
"formation.codeNiveauDiplome",
])
.execute();

return statsSortie.reduce(
(acc, cur) => {
acc[cur.codeRegion] = acc[cur.codeRegion] || {};
acc[cur.codeRegion][cur.codeNiveauDiplome] = {
tauxInsertion: cur.tauxInsertion,
tauxPoursuite: cur.tauxPoursuite,
};
return acc;
},
{} as Record<
string,
Record<string, { tauxInsertion: number; tauxPoursuite: number }>
>
);
};

export const getStatsSortieParRegions = async ({
codeRegion,
codeDepartement,
codeNiveauDiplome,
millesimeSortie = "2020_2021",
}: {
codeRegion?: string | string[];
codeDepartement?: string | string[];
codeNiveauDiplome?: string[];
millesimeSortie?: string;
}) => {
const statsSortie = await getStatsSortieBase({
codeRegion,
codeDepartement,
codeNiveauDiplome,
millesimeSortie,
})
.select(["indicateurRegionSortie.codeRegion"])
.groupBy(["indicateurRegionSortie.codeRegion"])
.execute();

return statsSortie.reduce(
(acc, cur) => {
acc[cur.codeRegion] = {
tauxInsertion: cur.tauxInsertion,
tauxPoursuite: cur.tauxPoursuite,
};
return acc;
},
{} as Record<string, { tauxInsertion: number; tauxPoursuite: number }>
);
};

export const getStatsSortie = async ({
codeRegion,
codeDepartement,
codeNiveauDiplome,
millesimeSortie = "2020_2021",
}: {
codeRegion?: string | string[];
codeDepartement?: string | string[];
codeNiveauDiplome?: string[];
millesimeSortie?: string;
}) => {
const statsSortie = await getStatsSortieBase({
codeRegion,
codeDepartement,
codeNiveauDiplome,
millesimeSortie,
}).executeTakeFirstOrThrow();

return statsSortie;
};
16 changes: 0 additions & 16 deletions server/src/modules/data/services/formatMillesime.ts

This file was deleted.

29 changes: 29 additions & 0 deletions server/src/modules/data/services/getMillesime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export const getMillesimePrecedent = (millesimeSortie: string): string =>
`${parseInt(millesimeSortie.split("_")[0]) - 1}_${
parseInt(millesimeSortie.split("_")[1]) - 1
}`;

export const getMillesimeSuivant = (millesimeSortie: string): string =>
`${parseInt(millesimeSortie.split("_")[0]) + 1}_${
parseInt(millesimeSortie.split("_")[1]) + 1
}`;

export const getMillesime = ({
millesimeSortie,
offset,
}: {
millesimeSortie: string;
offset: number;
}): string =>
`${parseInt(millesimeSortie.split("_")[0]) + offset}_${
parseInt(millesimeSortie.split("_")[1]) + offset
}`;

export const getMillesimeFromRentreeScolaire = ({
rentreeScolaire,
offset,
}: {
rentreeScolaire: string;
offset: number;
}): string =>
`${+rentreeScolaire + (offset - 2)}_${+rentreeScolaire + (offset - 1)}`;
92 changes: 92 additions & 0 deletions server/src/modules/data/services/getPositionQuadrant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
export const getPositionQuadrant = (
formation: {
tauxInsertion?: string | number;
tauxPoursuite?: string | number;
},
moyenne?: {
tauxInsertion?: string | number;
tauxPoursuite?: string | number;
}
): string => {
if (
!formation.tauxInsertion ||
!formation.tauxPoursuite ||
!moyenne?.tauxInsertion ||
!moyenne.tauxPoursuite
)
return "Hors quadrant";

const tauxInsertion =
typeof formation.tauxInsertion === "string"
? parseInt(formation.tauxInsertion)
: formation.tauxInsertion;
const tauxPoursuite =
typeof formation.tauxPoursuite === "string"
? parseInt(formation.tauxPoursuite)
: formation.tauxPoursuite;
const tauxInsertionMoyen =
typeof moyenne.tauxInsertion === "string"
? parseInt(moyenne.tauxInsertion)
: moyenne.tauxInsertion;
const tauxPoursuiteMoyen =
typeof moyenne.tauxPoursuite === "string"
? parseInt(moyenne.tauxPoursuite)
: moyenne.tauxPoursuite;

if (
tauxInsertion >= tauxInsertionMoyen &&
tauxPoursuite >= tauxPoursuiteMoyen
) {
return "Q1";
} else if (
tauxInsertion >= tauxInsertionMoyen &&
tauxPoursuite < tauxPoursuiteMoyen
) {
return "Q2";
} else if (
tauxInsertion < tauxInsertionMoyen &&
tauxPoursuite >= tauxPoursuiteMoyen
) {
return "Q3";
} else if (
tauxInsertion < tauxInsertionMoyen &&
tauxPoursuite < tauxPoursuiteMoyen
) {
return "Q4";
} else return "Hors quadrant";
};

export const filterPositionQuadrant = (
formations: { positionQuadrant: string }[],
positionQuadrantFilter?: string
) => {
if (!positionQuadrantFilter || positionQuadrantFilter === "all")
return formations;
return formations.filter(
(formation) => formation.positionQuadrant === positionQuadrantFilter
);
};

export const orderPositionQuadrant = (
formations: { positionQuadrant: string }[],
orderBy?: { column: string; order: "asc" | "desc" }
) => {
if (orderBy && orderBy.column === "positionQuadrant")
return formations.sort((a, b) =>
orderBy.order === "asc"
? a.positionQuadrant.localeCompare(b.positionQuadrant)
: b.positionQuadrant.localeCompare(a.positionQuadrant)
);
return formations;
};

export const filterOrderPositionQuadrant = (
formations: { positionQuadrant: string }[],
positionQuadrantFilter?: string,
orderBy?: { column: string; order: "asc" | "desc" }
) => {
return orderPositionQuadrant(
filterPositionQuadrant(formations, positionQuadrantFilter),
orderBy
);
};
13 changes: 13 additions & 0 deletions server/src/modules/data/services/getRentreeScolaire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const getRentreeScolairePrecedente = (rentreeScolaire: string): string =>
`${parseInt(rentreeScolaire) - 1}`;

export const getRentreeScolaireSuivante = (rentreeScolaire: string): string =>
`${parseInt(rentreeScolaire) + 1}`;

export const getRentreeScolaire = ({
rentreeScolaire,
offset,
}: {
rentreeScolaire: string;
offset: number;
}): string => `${+rentreeScolaire - offset}`;
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const StatsDemandesItem = z.object({
devenirFavorable: z.coerce.number().optional(),
pression: z.coerce.number().optional(),
nbEtablissement: z.coerce.number().optional(),
positionCadran: z.string().optional(),
positionQuadrant: z.string().optional(),
tauxInsertionMoyen: z.coerce.number().optional(),
tauxPoursuiteMoyen: z.coerce.number().optional(),
});
Expand Down Expand Up @@ -76,7 +76,7 @@ export const countRestitutionIntentionsStatsSchema = {
amiCMA: z.string().optional(),
secteur: z.string().optional(),
compensation: z.string().optional(),
positionCadran: z.string().optional(),
positionQuadrant: z.string().optional(),
order: z.enum(["asc", "desc"]).optional(),
orderBy: StatsDemandesItem.keyof().optional(),
}),
Expand Down
Loading
Loading