Skip to main content
Sign in
Snippets Groups Projects
Commit 92049d83 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Don't fail when there is a discontinuity of legislatures

parent 834cff73
No related branches found
No related tags found
No related merge requests found
...@@ -199,19 +199,19 @@ export function getOrganeAtDate( ...@@ -199,19 +199,19 @@ export function getOrganeAtDate(
organes: Organe[], organes: Organe[],
date: string, date: string,
): Organe | undefined { ): Organe | undefined {
let found: Organe | undefined = undefined // Sometimes, for example for the legislatures during the dissolution of 2024-06-09,
for (const organe of organes) { // there is a lapse of days between the end of an organe and the creation of a new one.
if ((organe.viMoDe.dateDebut as unknown as string) > date) { // When it occurs, assume that the previous organe continues until the next one begins.
break // => Don't use organe.viMoDe.dateFin.
} //
if ( // Note: This function assumes that organes are sorted in chronological order of
organe.viMoDe.dateFin === undefined || // organe.viMoDe.dateDebut.
(organe.viMoDe.dateFin as unknown as string) >= date for (const organe of organes.reverse()) {
) { if ((organe.viMoDe.dateDebut as unknown as string) <= date) {
found = organe return organe
} }
} }
return found return undefined
} }
export function hashEcheancier(echeancier: Echeancier): string { export function hashEcheancier(echeancier: Echeancier): string {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment