feat: Améliore gestion des Date d'évenement null
parent
f1d3e9aa0a
commit
39f46a596c
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
|
|
@ -23,10 +23,11 @@ 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.");
|
||||
process.exit(1);
|
||||
console.error("Found consistency issues:");
|
||||
console.error(consistencyIssues);
|
||||
if (consistencyIssues.find((issue) => !issue.canIgnore)) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const currentDate = new Date(Date.now());
|
||||
|
|
Loading…
Reference in New Issue