Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gBusato committed Feb 13, 2025
1 parent 0a961c9 commit dee2b82
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,14 @@ export const getStatsRegions = async ({
eb.ref("demandes.codeRegion").as("codeRegion"),
eb.fn.coalesce("effectifs.effectif", eb.val(0)).as("effectif"),
eb.fn.coalesce("demandes.placesTransformees", eb.val(0)).as("placesTransformees"),
eb.fn.coalesce(
sql<number>`CASE
WHEN ${eb.fn.coalesce("effectifs.effectif", eb.val(0))} = 0 THEN 0
sql<number>`CASE
WHEN ${eb.ref("effectifs.effectif")} IS NULL THEN NULL
ELSE ROUND( CAST(
(${eb.fn.coalesce("demandes.placesTransformees", eb.val(0))}::float /
${eb.fn.coalesce("effectifs.effectif", eb.val(0))}::float) AS numeric),
5
)
END`
, eb.val(0)).as("tauxTransformationCumule")
END`.as("tauxTransformationCumule")
])
.$castTo<{codeRegion: string; effectif: number; placesTransformees: number; tauxTransformationCumule: number;}>())
.selectFrom("region")
Expand All @@ -105,10 +103,10 @@ export const getStatsRegions = async ({
.select((eb) => [
eb.ref("region.codeRegion").as("codeRegion"),
eb.ref("region.libelleRegion").as("libelleRegion"),
eb.fn.coalesce(sql<number>`ROUND(CAST((${eb.ref("indicateursIJ.tauxChomage")}::float / ${eb.val(100)}::float) AS numeric), 5)`, eb.val(0)) .as("tauxChomage"),
eb.fn.coalesce(eb.ref("indicateursIJ.tauxInsertion"), eb.val(0)).as("tauxInsertion"),
eb.fn.coalesce(eb.ref("indicateursIJ.tauxPoursuite"), eb.val(0)).as("tauxPoursuite"),
eb.fn.coalesce(eb.ref("tauxTransformationCumule.tauxTransformationCumule"), eb.val(0)).as("tauxTransformationCumule"),
sql<number>`ROUND(CAST((${eb.ref("indicateursIJ.tauxChomage")}::float / ${eb.val(100)}::float) AS numeric), 5)`.as("tauxChomage"),
eb.ref("indicateursIJ.tauxInsertion").as("tauxInsertion"),
eb.ref("indicateursIJ.tauxPoursuite").as("tauxPoursuite"),
eb.ref("tauxTransformationCumule.tauxTransformationCumule").as("tauxTransformationCumule"),
])
.$call((q) => {
if (!orderBy) return q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ export const VueRegionAcademieSection = ({
{region.libelleRegion}
</Td>
<Td isNumeric backgroundColor={tdBgColor}>
{formatPercentage(region.tauxTransformationCumule ?? 0, 1, "-")}
{formatPercentage(region.tauxTransformationCumule, 1, "-")}
</Td>
<Td isNumeric backgroundColor={tdBgColor}>
{formatPercentage(region.tauxPoursuite ?? 0, 0, "-")}
{formatPercentage(region.tauxPoursuite, 0, "-")}
</Td>
<Td isNumeric backgroundColor={tdBgColor}>
{formatPercentage(region.tauxInsertion ?? 0, 0, "-")}
{formatPercentage(region.tauxInsertion, 0, "-")}
</Td>
<Td isNumeric backgroundColor={tdBgColor}>
{formatPercentage(region.tauxChomage ?? 0, 1, "-")}
{formatPercentage(region.tauxChomage, 1, "-")}
</Td>
</Tr>
);
Expand Down
14 changes: 14 additions & 0 deletions ui/components/CartoGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ export const CartoGraph = ({
label: string;
color: string;
}[] => {
if(customPiecesSteps) {
const colorRange = colorPalette;

return customPiecesSteps.map((step, index, steps) => {
const isLastStep = index + 1 === steps.length;
return {
min: step[0],
max: step[1],
label: isLastStep ? `> ${step[0]}%` : `< ${step[1]}%`,
color: colorRange[index],
};
});
}

// Filtrer les valeurs valides et les trier
const validData = Array.from(graphData?.map((it) => it.value ?? -1) ?? [])
.filter((value) => value !== -1)
Expand Down

0 comments on commit dee2b82

Please sign in to comment.