Skip to content

Commit

Permalink
fix: mise a jour des indicateurs groupe par formation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomarom committed May 7, 2024
1 parent 9bc393c commit af55ef7
Showing 1 changed file with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,40 @@ export const getOrganismeIndicateursEffectifsParFormation = async (
ctx: AuthContext,
organismeId: ObjectId,
filters: FullEffectifsFilters
) => [
...(await getOrganismeIndicateursEffectifsParFormationGenerique(ctx, organismeId, filters, effectifsDb())),
...(await getOrganismeIndicateursEffectifsParFormationGenerique(ctx, organismeId, filters, effectifsDECADb(), true)),
];
) => {
const indicateurs = [
...(await getOrganismeIndicateursEffectifsParFormationGenerique(ctx, organismeId, filters, effectifsDb())),
...(await getOrganismeIndicateursEffectifsParFormationGenerique(
ctx,
organismeId,
filters,
effectifsDECADb(),
true
)),
];

const mapRNCP = indicateurs.reduce((acc, { rncp_code, ...rest }) => {
const rncp = rncp_code ?? "null";
return acc[rncp]
? {
...acc,
[rncp]: {
rncp_code,
apprentis: acc[rncp].apprentis + rest.apprentis,
abandons: acc[rncp].abandons + rest.abandons,
inscrits: acc[rncp].inscrits + rest.inscrits,
apprenants: acc[rncp].apprenants + rest.apprenants,
rupturants: acc[rncp].rupturants + rest.rupturants,
},
}
: {
...acc,
[rncp]: {
rncp_code,
...rest,
},
};
}, {});

return Object.values(mapRNCP);
};

0 comments on commit af55ef7

Please sign in to comment.