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