feat: Améliore gestion des Date d'évenement null
parent
f1d3e9aa0a
commit
39f46a596c
|
@ -81,12 +81,15 @@ export type CategorieEvenement =
|
||||||
export function isEvenementInPeriod(
|
export function isEvenementInPeriod(
|
||||||
evt: EvenementFamille,
|
evt: EvenementFamille,
|
||||||
period: Period
|
period: Period
|
||||||
): unknown {
|
): boolean {
|
||||||
return evt.Date && isPeriodContaining(period, evt.Date);
|
return evt.Date !== null && isPeriodContaining(period, evt.Date);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isEvenementBefore(evt: EvenementFamille, date: Date): boolean {
|
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 {
|
export function isValidEvenementFamille(str: string | null): boolean {
|
||||||
|
|
|
@ -10,6 +10,7 @@ export function checkDataConsistency(families: Famille[]): ConsistencyIssue[] {
|
||||||
export type ConsistencyIssue = {
|
export type ConsistencyIssue = {
|
||||||
issueType: string;
|
issueType: string;
|
||||||
familyId: string;
|
familyId: string;
|
||||||
|
canIgnore?: boolean;
|
||||||
};
|
};
|
||||||
function checkFamilyDataConsistency(family: Famille) {
|
function checkFamilyDataConsistency(family: Famille) {
|
||||||
const consistencyIssues: ConsistencyIssue[] = [];
|
const consistencyIssues: ConsistencyIssue[] = [];
|
||||||
|
@ -51,7 +52,16 @@ function checkFamilyDataConsistency(family: Famille) {
|
||||||
...family.Evenements.filter((e) => !isValidEvenementFamille(e.Type)).map(
|
...family.Evenements.filter((e) => !isValidEvenementFamille(e.Type)).map(
|
||||||
(e) => ({
|
(e) => ({
|
||||||
familyId: family.Titre,
|
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...");
|
console.log("Checking Data Consistency issues...");
|
||||||
const consistencyIssues = checkDataConsistency(families);
|
const consistencyIssues = checkDataConsistency(families);
|
||||||
if (consistencyIssues.length > 0) {
|
if (consistencyIssues.length > 0) {
|
||||||
console.log("Found consistency issues:");
|
console.error("Found consistency issues:");
|
||||||
console.log(consistencyIssues);
|
console.error(consistencyIssues);
|
||||||
console.log("Exiting.");
|
if (consistencyIssues.find((issue) => !issue.canIgnore)) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentDate = new Date(Date.now());
|
const currentDate = new Date(Date.now());
|
||||||
|
|
Loading…
Reference in New Issue