diff --git a/src/data/TypeEvenementsPenal.ts b/src/data/TypeEvenementsPenal.ts index 13e3e04..4d44b67 100644 --- a/src/data/TypeEvenementsPenal.ts +++ b/src/data/TypeEvenementsPenal.ts @@ -27,13 +27,13 @@ export const typesEvenementsPenal = [ "Administrateur AD'HOC", "Relaxe Tribunal correctionnel", "Vice de procédure tribunal correctionnel", - "Procès appel TC", "Appel du parquet", + "Procès appel TC", // Tribunal de police "Tribunal de police judiciaire", + "Relaxe Tribunal de police", + "Appel Tribunal Police opposition ordonnance pénale", "Procès appel TP", -"Relaxe Tribunal de police", -"Appel Tribunal Police opposition ordonnance pénale" // [,,,"Amendes",,,,"Classement sous condition","Information non médico-sociale"] ] as const; diff --git a/src/statistiques/v2/penales/InfoTribunalCorrectionnel.ts b/src/statistiques/v2/penales/InfoTribunalCorrectionnel.ts new file mode 100644 index 0000000..6418e1a --- /dev/null +++ b/src/statistiques/v2/penales/InfoTribunalCorrectionnel.ts @@ -0,0 +1,10 @@ +import { EvenementFamille } from "../../../data/EvenementFamille"; + + +export type InfoTribunalCorrectionnel = { + evtTribunal: EvenementFamille; + evtRelaxe?: EvenementFamille; + evtAdminAdhoc?: EvenementFamille; + evtViceDeProcedure?: EvenementFamille; + evtAppel?: EvenementFamille; +}; diff --git a/src/statistiques/v2/penales/StatsPenales.ts b/src/statistiques/v2/penales/StatsPenales.ts index e2bf1f6..ec75b76 100644 --- a/src/statistiques/v2/penales/StatsPenales.ts +++ b/src/statistiques/v2/penales/StatsPenales.ts @@ -1,6 +1,6 @@ import { StatsType } from "../desc/StatsDesc"; -export const statsTribunalDesc = { +export const statsTribunalCorrectionnelDesc = { nbFamillesConvoquees: { label: "Nb familles convoquées mais pas encore passées", }, @@ -91,15 +91,15 @@ export const statsPenalesDesc = { tribunalCorrectionnel1: { label: "Tribunal Correctionnel 1er passage", - stats: statsTribunalDesc, + stats: statsTribunalCorrectionnelDesc, }, tribunalCorrectionnel2: { label: "Tribunal Correctionnel 2eme passage", - stats: statsTribunalDesc, + stats: statsTribunalCorrectionnelDesc, }, tribunalCorrectionnel3: { label: "Tribunal Correctionnel 3eme passage", - stats: statsTribunalDesc, + stats: statsTribunalCorrectionnelDesc, }, nbFamilleAvecStageParentalité: { @@ -108,8 +108,18 @@ export const statsPenalesDesc = { nbFamilleAvecRequisitionJudiciaire: { label: "Nb Familles avec Réquisition Judiciaire", }, - nbFamillesTribunalDePolice: { - label: "Nb familles avec Tribunal de police", + tribunalDePolice: { + label: "Tribunal de Police", + stats: { + nbFamilles: { + label: "Nb familles avec Tribunal de police", + }, + nbFamillesAppel: { + label: "Nb familles ayant fait appel", + },nbFamillesRelaxee: { + label: "Nb familles relaxées", + }, + }, }, intervalGendarmerieProcureur: { label: "Délai moyen entre Gendarmerie et Procureur", diff --git a/src/statistiques/v2/penales/buildInfoTribunauxCorrectionnel.ts b/src/statistiques/v2/penales/buildInfoTribunauxCorrectionnel.ts new file mode 100644 index 0000000..f745530 --- /dev/null +++ b/src/statistiques/v2/penales/buildInfoTribunauxCorrectionnel.ts @@ -0,0 +1,43 @@ +import { Famille } from "../../../data/Famille"; +import { isTribunalCorrectionnel } from "./computeStatsPenales"; +import { InfoTribunalCorrectionnel } from "./InfoTribunalCorrectionnel"; + +export function buildInfoTribunauxCorrectionnel(f: Famille): InfoTribunalCorrectionnel[] { + const evtTribunaux = f.EvenementsEL.filter(isTribunalCorrectionnel); + + return evtTribunaux.map((evtTribunal, index) => { + const prevEvtTrib = (index - 1 >= 0) ? evtTribunaux[index - 1] : null; + const nextEvtTrib = index + 1 < evtTribunaux.length ? evtTribunaux[index + 1] : null; + + const eventsBetweenPreviousTribAndCurrentTrib = f.EvenementsEL.filter( + (e) => evtTribunal.Date != null && + e.Date != null && + e.Date <= evtTribunal.Date && + (prevEvtTrib?.Date == null || e.Date > prevEvtTrib.Date) + ); + + const eventsBetweenCurrentTribAndNextTrib = f.EvenementsEL.filter( + (e) => evtTribunal.Date != null && + e.Date != null && + e.Date >= evtTribunal.Date && + (nextEvtTrib?.Date == null || e.Date < nextEvtTrib.Date) + ); + + return { + evtTribunal: evtTribunal, + evtAdminAdhoc: eventsBetweenPreviousTribAndCurrentTrib.find( + (e) => e.Type === "Administrateur AD'HOC" + ), + evtAppel: eventsBetweenCurrentTribAndNextTrib.find( + (e) => (index === 0 && e.Type === "Appel jugement Tribunal Correctionnel") || + (index === 1 && e.Type == "Appel du 2ème jugement TC") + ), + evtViceDeProcedure: eventsBetweenCurrentTribAndNextTrib.find( + (e) => e.Type === "Vice de procédure tribunal correctionnel" + ), + evtRelaxe: eventsBetweenCurrentTribAndNextTrib.find( + (e) => e.Type === "Relaxe Tribunal correctionnel" + ), + }; + }); +} diff --git a/src/statistiques/v2/penales/computeStatsPenales.ts b/src/statistiques/v2/penales/computeStatsPenales.ts index a05177d..4c9ce09 100644 --- a/src/statistiques/v2/penales/computeStatsPenales.ts +++ b/src/statistiques/v2/penales/computeStatsPenales.ts @@ -15,19 +15,13 @@ import { filterFamillesWithOneOfEvenements } from "../filterFamillesWithOneOfEve import { filterFamillesWithOneOfEvenementsOfType } from "../filterFamillesWithOneOfEvenementsOfType"; import { StatsPenales } from "./StatsPenales"; import { nbFamillesAvecPagesLiees } from "./nbFamillesAvecPagesLiees"; +import { buildInfoTribunauxCorrectionnel } from "./buildInfoTribunauxCorrectionnel"; +import { InfoTribunalCorrectionnel } from "./InfoTribunalCorrectionnel"; type FamilleAvecInfoTribunaux = Famille & { infoTribunaux: InfoTribunalCorrectionnel[]; }; -type InfoTribunalCorrectionnel = { - evtTribunal: EvenementFamille; - evtRelaxe?: EvenementFamille; - evtAdminAdhoc?: EvenementFamille; - evtViceDeProcedure?: EvenementFamille; - evtAppel?: EvenementFamille; -}; - export function computeStatsPenales(familles: Famille[]): StatsPenales { const famillesResistantesOuEx = familles.filter( (f) => isResistant(f) || isExResistant(f) @@ -58,7 +52,7 @@ export function computeStatsPenales(familles: Famille[]): StatsPenales { const famillesAvecInfoTribunaux: FamilleAvecInfoTribunaux[] = famillesResistantesOuEx.map((f) => { - const infoTribunaux = buildInfoTribunaux(f); + const infoTribunaux = buildInfoTribunauxCorrectionnel(f); return { ...f, infoTribunaux: infoTribunaux, @@ -128,12 +122,7 @@ export function computeStatsPenales(familles: Famille[]): StatsPenales { ) ), - nbFamillesTribunalDePolice: nbFamillesAvecPagesLiees( - filterFamillesWithOneOfEvenementsOfType( - famillesResistantesOuEx, - "Tribunal de police judiciaire" - ) - ), + tribunalDePolice: computeTribunalPolice(famillesResistantesOuEx), intervalGendarmerieProcureur: computeIntervalGendarmerieProcureur(familles), intervalProcureurTribunalCorrectionnel: @@ -142,6 +131,31 @@ export function computeStatsPenales(familles: Famille[]): StatsPenales { return statsPenales; } +function computeTribunalPolice( + famillesResistantesOuEx: Famille[] +): StatsPenales["tribunalDePolice"] { + return { + nbFamilles: nbFamillesAvecPagesLiees( + filterFamillesWithOneOfEvenementsOfType( + famillesResistantesOuEx, + "Tribunal de police judiciaire" + ) + ), + nbFamillesAppel: nbFamillesAvecPagesLiees( + filterFamillesWithOneOfEvenementsOfType( + famillesResistantesOuEx, + "Appel Tribunal Police opposition ordonnance pénale" + ) + ), + nbFamillesRelaxee: nbFamillesAvecPagesLiees( + filterFamillesWithOneOfEvenementsOfType( + famillesResistantesOuEx, + "Relaxe Tribunal de police" + ) + ), + }; +} + function computeCrpc( famillesResistantesOuEx: Famille[] ): StatsPenales["procureur"]["crpc"] { @@ -235,9 +249,12 @@ function computeTribunalCorrectionnel( nbFamillesAppelDuJugement: nbFamillesAvecPagesLiees( famillesAppelDuJugement ), - nbFamillesAdministrateurAdhoc: nbFamillesAvecPagesLiees(famillesAdministrateurAdhoc), - nbFamillesViceDeProcedure: nbFamillesAvecPagesLiees(famillesViceDeProcedure), - + nbFamillesAdministrateurAdhoc: nbFamillesAvecPagesLiees( + famillesAdministrateurAdhoc + ), + nbFamillesViceDeProcedure: nbFamillesAvecPagesLiees( + famillesViceDeProcedure + ), }; } @@ -297,51 +314,6 @@ function computeIntervalProcureurTribunalCorrectionnel( return average(intervals); } -function isTribunalCorrectionnel(e: EvenementFamille): boolean { +export function isTribunalCorrectionnel(e: EvenementFamille): boolean { return e.Type === "Tribunal correctionnel"; } - -function buildInfoTribunaux(f: Famille): InfoTribunalCorrectionnel[] { - const evtTribunaux = f.EvenementsEL.filter(isTribunalCorrectionnel); - - return evtTribunaux.map((evtTribunal, index) => { - const prevEvtTrib = ( index - 1 >= 0) ? evtTribunaux[index - 1] : null; - const nextEvtTrib = - index + 1 < evtTribunaux.length ? evtTribunaux[index + 1] : null; - - const eventsBetweenPreviousTribAndCurrentTrib = f.EvenementsEL.filter( - (e) => - evtTribunal.Date != null && - e.Date != null && - e.Date <= evtTribunal.Date && - (prevEvtTrib?.Date == null || e.Date > prevEvtTrib.Date) - ); - - const eventsBetweenCurrentTribAndNextTrib = f.EvenementsEL.filter( - (e) => - evtTribunal.Date != null && - e.Date != null && - e.Date >= evtTribunal.Date && - (nextEvtTrib?.Date == null || e.Date < nextEvtTrib.Date) - ); - - return { - evtTribunal: evtTribunal, - evtAdminAdhoc: eventsBetweenPreviousTribAndCurrentTrib.find( - (e) => e.Type === "Administrateur AD'HOC" - ), - evtAppel: eventsBetweenCurrentTribAndNextTrib.find( - (e) => - (index === 0 && e.Type === "Appel jugement Tribunal Correctionnel") || - (index === 1 && e.Type == "Appel du 2ème jugement TC") - ), - evtViceDeProcedure: eventsBetweenCurrentTribAndNextTrib.find( - (e) => e.Type === "Vice de procédure tribunal correctionnel" - ), - evtRelaxe: eventsBetweenCurrentTribAndNextTrib.find( - (e) => e.Type === "Relaxe Tribunal correctionnel" - ), - - }; - }); -}