Skip to content

Commit

Permalink
feat: affichage des admissions pour les bacs pro famille de metiers (#23
Browse files Browse the repository at this point in the history
)

feat: affichage des admissions pour les bacs pro famille de metiers
  • Loading branch information
K4ST0R authored Dec 19, 2024
1 parent d6cb025 commit 83b011d
Show file tree
Hide file tree
Showing 13 changed files with 36,012 additions and 35,358 deletions.
71,238 changes: 35,896 additions & 35,342 deletions server/data/acce_etablissements.csv

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions server/migrations/20241217131448_indicateur-entree-annee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Kysely, sql } from "kysely";

export async function up(db: Kysely<any>): Promise<void> {
await db.executeQuery(
sql`
ALTER TABLE "indicateurEntree"
ADD COLUMN "effectifsAnnee" varchar;
`.compile(db)
);
}

export async function down(db: Kysely<any>): Promise<void> {
await db.executeQuery(
sql`
ALTER TABLE "indicateurEntree"
DROP COLUMN IF EXISTS "effectifsAnnee";
`.compile(db)
);
}
3 changes: 2 additions & 1 deletion server/src/common/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface Formation {
descriptionPoursuiteEtudes: string | null;
familleMetierId: string | null;
id: Generated<string>;
isAnneeCommune: boolean | null;
isAnneeCommune: Generated<boolean | null>;
libelle: string | null;
mef11: string | null;
niveauDiplome: Generated<string>;
Expand Down Expand Up @@ -161,6 +161,7 @@ export interface IndicateurEntree {
capacite: number | null;
createdAt: Generated<Timestamp>;
effectifs: number | null;
effectifsAnnee: Generated<string>;
formationEtablissementId: string | null;
id: Generated<string>;
premiersVoeux: number | null;
Expand Down
26 changes: 26 additions & 0 deletions server/src/common/repositories/indicateurEntree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { SqlRepository } from "./base.js";
import { kdb as defaultKdb } from "../db/db.js";
import { DB } from "../db/schema.js";

export class IndicateurEntreeRepository extends SqlRepository<DB, "indicateurEntree"> {
constructor(kdb = defaultKdb) {
super(
"indicateurEntree",
{
id: null,
formationEtablissementId: null,
capacite: null,
effectifs: null,
effectifsAnnee: null,
premiersVoeux: null,
rentreeScolaire: null,
tauxPression: null,
createdAt: null,
updatedAt: null,
},
kdb
);
}
}

export default new IndicateurEntreeRepository();
24 changes: 21 additions & 3 deletions server/src/jobs/formations/importIndicateurEntree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import config from "#src/config.js";
import FormationEtablissementRepository from "#src/common/repositories/formationEtablissement";
import { kdb, upsert } from "#src/common/db/db";
import { cfdsParentAndChildren } from "#src/queries/cfdsParentAndChildren.js";
import IndicateurEntreeRepository from "#src/common/repositories/indicateurEntree";

const logger = getLoggerWithContext("import");

Expand Down Expand Up @@ -80,18 +81,35 @@ export async function importIndicateurEntree(options = { exportEtablissementsOri
filterData((data) => data),
writeData(
async ({ formationEtablissement: { formationEtablissement, formation, etablissement }, data }) => {
const effectifsAnnee = (formation.familleMetierId ? ["1", "2"] : ["1"])
.filter((a) => data[`Année ${a}`] !== undefined)
.find((_) => true);

const indicateurEntree = {
formationEtablissementId: formationEtablissement.id,
rentreeScolaire: data["RS"],
capacite: formatInt(data["Capacité"]),
premiersVoeux: formatInt(data["Nb de premiers voeux"]),
// TODO: mieux gérer les spécialités
// Il y a les capacités uniquement pour la deuxième année
effectifs: formatInt(data["Année 1"]),
effectifs: effectifsAnnee ? formatInt(data[`Année ${effectifsAnnee}`]) : null,
effectifsAnnee,
tauxPression: formatFloat(data["Tx de pression"]),
};

try {
// Vérifie qu'il n'existe pas déjà un effectif pour une année antérieur
const previousYearExist = await IndicateurEntreeRepository.first({
formationEtablissementId: indicateurEntree.formationEtablissementId,
rentreeScolaire: indicateurEntree.rentreeScolaire,
});
if (
previousYearExist &&
previousYearExist.effectifsAnnee !== null &&
previousYearExist.effectifs !== null &&
previousYearExist.effectifsAnnee < indicateurEntree.effectifsAnnee
) {
return;
}

await upsert(
kdb,
"indicateurEntree",
Expand Down
3 changes: 3 additions & 0 deletions ui/app/(accompagnateur)/components/FormationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default React.memo(function FormationCard({
onMouseEnter,
onMouseLeave,
tabIndex,
focusHighlight = false,
withJPO = true,
withDuration = true,
style = undefined,
Expand All @@ -32,6 +33,7 @@ export default React.memo(function FormationCard({
onMouseEnter?: Function;
onMouseLeave?: Function;
tabIndex: number;
focusHighlight?: boolean;
withJPO?: boolean;
withDuration?: boolean;
style?: React.CSSProperties;
Expand All @@ -55,6 +57,7 @@ export default React.memo(function FormationCard({
tabIndex={tabIndex}
style={style}
type={"formation"}
focusHighlight={focusHighlight}
>
<Box style={{ padding: "1.25rem" }}>
<Stack direction={"row"} spacing={1} useFlexGap sx={{ flexWrap: "wrap", marginBottom: fr.spacing("3v") }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ export default function FormationsFamilleMetier({
css={css`
margin: 0;
& li {
font-size: ${small ? "0.875rem" : "1.125rem"};
font-size: ${small ? "1rem" : "1.125rem"};
line-height: ${small ? "1.5rem" : "1.75rem"};
padding-bottom: 0;
}
& li:not(:last-child) {
margin-bottom: ${small ? "0.25rem" : "0.25rem"};
}
`}
>
{formations.map((detail, index) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/(accompagnateur)/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const title = "C’EST QUI LE PRO ?";
export const title = "C’est qui le pro ?";
export const tagline = "Découvre les formations professionnelles en sortie de collège";
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function FormationSimilare({ formationDetail }: { formationDetail
<Grow in={true} unmountOnExit key={`formation-similaire-${index}`}>
<Grid item xs={12 / eltByLine}>
<FormationCard
focusHighlight
formationDetail={formationDetail}
latitude={latitude}
longitude={longitude}
Expand All @@ -73,7 +74,6 @@ export default function FormationSimilare({ formationDetail }: { formationDetail
display: "flex",
justifyContent: "flex-start",
alignItems: "flex-start",
backgroundColor: "white",
}}
/>
</Grid>
Expand Down
6 changes: 6 additions & 0 deletions ui/app/(accompagnateur)/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

body {
--hover: #ECECFE;
}


[target=_blank]::after {
-webkit-mask-image: url("../dsfr/icons/external-link-fill.svg") !important;
mask-image: url("../dsfr/icons/external-link-fill.svg") !important;
Expand Down
27 changes: 25 additions & 2 deletions ui/app/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type CardProps = Omit<MUICardProps, "title"> & {
selected?: boolean;
actionProps?: CardActionAreaProps;
type?: "details" | "formation";
focusHighlight?: boolean;
};

const StyledLink = styled(Link)`
Expand All @@ -35,6 +36,7 @@ export function Card({ title, link, linkTarget, style, children, className, acti
return (
<CardActionArea
{...actionProps}
disableRipple
className={className}
style={style}
onClick={(e) => {
Expand Down Expand Up @@ -112,12 +114,33 @@ export default styled(Card)<CardProps>`
& .MuiContainer-root {
padding: ${fr.spacing("3v")};
}
`;
}`;
}
}};
${({ selected }) => {
return !isNil(selected) && selected ? "background-color: var(--hover);" : "";
}}
${({ focusHighlight }) => {
return (
focusHighlight ||
`& .MuiCardActionArea-focusHighlight {
display: none;
}`
);
}}
& .MuiButtonBase-root {
background-color: white;
}
& .MuiButtonBase-root:hover {
background-color: var(--hover);
}
&.MuiButtonBase-root {
background-color: white;
}
`;
4 changes: 2 additions & 2 deletions ui/app/components/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const TagDuree = styled(TagStyled)`
`;

export const TagApprentissage = styled(TagStyled)`
color: var(--warning-425-625-hover);
background-color: var(--error-950-100);
color: ${fr.colors.decisions.text.default.success.default};
background-color: ${fr.colors.options.greenMenthe._975_75.default};
`;

export default TagStyled;
10 changes: 5 additions & 5 deletions ui/app/services/formation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormationDomaine, FormationTag } from "shared";
import CalendarIcon from "#/app/components/icon/CalendarIcon";
import { FrCxArg, FrIconClassName, RiIconClassName } from "@codegouvfr/react-dsfr";
import { FrCxArg, FrIconClassName, RiIconClassName, fr } from "@codegouvfr/react-dsfr";
import MoneyIcon from "../components/icon/MoneyIcon";

export type FormationTagType = {
Expand All @@ -14,16 +14,16 @@ export const FORMATION_TAG: FormationTagType[] = [
{
tag: FormationTag.POUR_TRAVAILLER_RAPIDEMENT,
libelle: "TAUX D'INSERTION FAVORABLE",
color: "#18753c",
bgColor: "var(--success-975-75)",
color: fr.colors.decisions.text.default.success.default,
bgColor: fr.colors.decisions.background.contrast.success.default,
icon: MoneyIcon,
},

{
tag: FormationTag.FAIBLE_TAUX_PRESSION,
libelle: "TAUX DE PRESSION FAIBLE",
color: "var(--info-425-625)",
bgColor: "var(--info-975-75)",
color: fr.colors.decisions.text.default.success.default,
bgColor: fr.colors.decisions.background.contrast.success.default,
icon: CalendarIcon,
},
];
Expand Down

0 comments on commit 83b011d

Please sign in to comment.