feat: Améliore gestion des Date d'évenement null

wip-related-pages
sebastien.arod@gmail.com 2024-06-06 21:48:10 +02:00
parent f1d3e9aa0a
commit 39f46a596c
3 changed files with 22 additions and 8 deletions

View File

@ -81,12 +81,15 @@ export type CategorieEvenement =
export function isEvenementInPeriod(
evt: EvenementFamille,
period: Period
): unknown {
return evt.Date && isPeriodContaining(period, evt.Date);
): boolean {
return evt.Date !== null && isPeriodContaining(period, evt.Date);
}
export function isEvenementBefore(evt: EvenementFamille, date: Date): boolean {
return evt.Date !== null && evt.Date < date;
if (evt.Date === null) {
return true;
}
return evt.Date < date;
}
export function isValidEvenementFamille(str: string | null): boolean {

View File

@ -10,6 +10,7 @@ export function checkDataConsistency(families: Famille[]): ConsistencyIssue[] {
export type ConsistencyIssue = {
issueType: string;
familyId: string;
canIgnore?: boolean;
};
function checkFamilyDataConsistency(family: Famille) {
const consistencyIssues: ConsistencyIssue[] = [];
@ -51,7 +52,16 @@ function checkFamilyDataConsistency(family: Famille) {
...family.Evenements.filter((e) => !isValidEvenementFamille(e.Type)).map(
(e) => ({
familyId: family.Titre,
issueType: "Unknown event Type: " + e.Type,
issueType: `Event ${e.notionId} has unknown event Type "${e.Type}"`,
})
)
);
consistencyIssues.push(
...family.Evenements.filter((e) => e.Type !== null && e.Date === null).map(
(e) => ({
familyId: family.Titre,
issueType: `Event ${e.notionId} with non null Type "${e.Type}" but null Date`,
canIgnore: true,
})
)
);

View File

@ -23,11 +23,12 @@ import { computeELStats } from "./statistiques/computeELStats";
console.log("Checking Data Consistency issues...");
const consistencyIssues = checkDataConsistency(families);
if (consistencyIssues.length > 0) {
console.log("Found consistency issues:");
console.log(consistencyIssues);
console.log("Exiting.");
console.error("Found consistency issues:");
console.error(consistencyIssues);
if (consistencyIssues.find((issue) => !issue.canIgnore)) {
process.exit(1);
}
}
const currentDate = new Date(Date.now());