feat: remplace nbFicheIntegrationParStatuts
remplace nbFicheIntegrationParStatuts par nbIntegrationsEnCours +nbFicheFamillesParStatutwip-related-pages
parent
65213126e1
commit
2394396b2c
|
@ -4,11 +4,7 @@ import { arePeriodsOverlaping } from "../period/arePeriodsOverlaping";
|
|||
import { isPeriodContaining } from "../period/isPeriodContaining";
|
||||
import { ContexteEntreeDC } from "./ContexteEntreeDC";
|
||||
import { EvenementFamille } from "./EvenementFamille";
|
||||
import {
|
||||
StatutFamille,
|
||||
StatutIntegrationEnCours,
|
||||
statutsIntegrationEnCours,
|
||||
} from "./StatutFamille";
|
||||
import { StatutFamille } from "./StatutFamille";
|
||||
import { StatutSocial } from "./StatutSocial";
|
||||
import { StatutPenal } from "./StatutPenal";
|
||||
|
||||
|
@ -52,12 +48,6 @@ export function isResistant(
|
|||
return por !== null && isPeriodContaining(por, date);
|
||||
}
|
||||
|
||||
export function isIntegration(famille: Famille) {
|
||||
return statutsIntegrationEnCours.includes(
|
||||
famille.Statut as StatutIntegrationEnCours
|
||||
);
|
||||
}
|
||||
|
||||
export function isExResistant(
|
||||
family: Famille,
|
||||
date: Date = new Date(Date.now())
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
export const statutsIntegrationEnCours = [
|
||||
"en réflexion",
|
||||
"Intégration à finaliser (vérification de la fiche))",
|
||||
"Intégration en cours",
|
||||
] as const;
|
||||
|
||||
export const statutsPreIntegration = ["en réflexion"] as const;
|
||||
|
||||
export const statutsIntegrationEnEchec = ["Abandon", "Incompatible"] as const;
|
||||
export const statutsFamille = [
|
||||
...statutsPreIntegration,
|
||||
"Résistant.e",
|
||||
"Ex résistant·e·s",
|
||||
...statutsIntegrationEnCours,
|
||||
...statutsIntegrationEnEchec,
|
||||
] as const;
|
||||
|
||||
export type StatutIntegrationEnCours =
|
||||
(typeof statutsIntegrationEnCours)[number];
|
||||
|
||||
export type StatutFamille = (typeof statutsFamille)[number];
|
||||
|
||||
export function isIntegrationEnCours(statut: StatutFamille): boolean {
|
||||
return statutsIntegrationEnCours.includes(
|
||||
statut as (typeof statutsIntegrationEnCours)[number]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,11 +28,12 @@ export const statsGeneralesDesc = {
|
|||
label: "Nb Familles par contexte d'entrée",
|
||||
type: "multi",
|
||||
},
|
||||
nbFicheIntegrationActiviteRecente: {
|
||||
label: "Nb fiche d'intégration avec une activité < 30j",
|
||||
nbIntegrationsEnCours: {
|
||||
label:
|
||||
"Nb d'intégrations en cours ( statuts Intégration en cours + Intégration à finaliser )",
|
||||
},
|
||||
nbFicheIntegrationParStatuts: {
|
||||
label: "Nb fiche d'intégration par statuts",
|
||||
nbFicheFamillesParStatut: {
|
||||
label: "Nb fiches famille par statut",
|
||||
type: "multi",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import { differenceInDays } from "date-fns";
|
||||
import {
|
||||
dureeResistanceInDays,
|
||||
Famille,
|
||||
isExResistant,
|
||||
isIntegration,
|
||||
isResistant,
|
||||
} from "../../../data/Famille";
|
||||
import { average } from "../../../utils/math/average";
|
||||
import { median } from "../../../utils/math/median";
|
||||
import { StatsGenerales } from "./StatsGenerales";
|
||||
import _, { countBy, uniq } from "lodash";
|
||||
import { isIntegrationEnCours } from "../../../data/StatutFamille";
|
||||
|
||||
export function computeStatsGenerales(familles: Famille[]): StatsGenerales {
|
||||
const famillesResistantesOrEx = familles.filter(
|
||||
|
@ -20,11 +19,6 @@ export function computeStatsGenerales(familles: Famille[]): StatsGenerales {
|
|||
const dureesResistances = famillesResistantesOrEx.map(
|
||||
(f) => dureeResistanceInDays(f)!
|
||||
);
|
||||
const now = new Date();
|
||||
const fichesIntegrationRecementModifiees = familles.filter(
|
||||
(f) =>
|
||||
isIntegration(f) && differenceInDays(now, f.DerniereModification) <= 30
|
||||
);
|
||||
const statsGenerales: StatsGenerales = {
|
||||
nbFamillesResistantesActuelles: famillesResistantes.length,
|
||||
nbFamillesResistantesActuellesOuPassees: famillesResistantesOrEx.length,
|
||||
|
@ -41,14 +35,10 @@ export function computeStatsGenerales(familles: Famille[]): StatsGenerales {
|
|||
nbFamillesParContexteDEntree: sortByKey(
|
||||
countBy(famillesResistantesOrEx, (f) => f.ContexteEntree)
|
||||
),
|
||||
nbFicheIntegrationActiviteRecente:
|
||||
fichesIntegrationRecementModifiees.length,
|
||||
nbFicheIntegrationParStatuts: sortByKey(
|
||||
countBy(
|
||||
familles.filter((f) => isIntegration(f)),
|
||||
(f) => f.Statut
|
||||
)
|
||||
),
|
||||
nbIntegrationsEnCours: familles.filter((f) =>
|
||||
isIntegrationEnCours(f.Statut)
|
||||
).length,
|
||||
nbFicheFamillesParStatut: sortByKey(countBy(familles, (f) => f.Statut)),
|
||||
};
|
||||
return statsGenerales;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue