diff --git a/package-lock.json b/package-lock.json index 1530d95d..638e1d98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "berlin-lea-performance-monitor", - "version": "1.11.3", + "version": "1.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "berlin-lea-performance-monitor", - "version": "1.11.3", + "version": "1.12.0", "dependencies": { "chart.js": "^3.9.1", "chartjs-adapter-moment": "^1.0.1", diff --git a/package.json b/package.json index df1fca7a..0538d1fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "berlin-lea-performance-monitor", - "version": "1.11.3", + "version": "1.12.0", "author": "David Leclerc", "main": "./src/index.ts", "scripts": { diff --git a/src/models/sessions/SessionHistory.ts b/src/models/sessions/SessionHistory.ts index e1646ec6..25b9711e 100644 --- a/src/models/sessions/SessionHistory.ts +++ b/src/models/sessions/SessionHistory.ts @@ -2,6 +2,7 @@ import { WEEKDAYS, WORKDAYS } from '../../constants/times'; import logger from '../../logger'; import { VersionedData, Weekday } from '../../types'; import { toCountsFromArray, unique } from '../../utils/array'; +import { isKnownEvent } from '../../utils/event'; import { formatDateForFilename, getWeekday } from '../../utils/locale'; import { sum } from '../../utils/math'; import TimeDuration from '../TimeDuration'; @@ -38,9 +39,10 @@ class SessionHistory { } public summarize() { - const errorCounts = this.getErrorCounts(); - const successTimes = this - .getSuccesses() + const knownErrorCounts = this.getErrorCounts(isKnownEvent); + const unknownErrorCounts = this.getErrorCounts(err => !isKnownEvent(err)); + + const successTimes = this.getSuccesses() .map(session => formatDateForFilename(session.getEndTime())); if (successTimes.length > 0) { @@ -49,10 +51,11 @@ class SessionHistory { logger.info(`There was never an appointment available.`); } - if (sum(Object.values(errorCounts)) > 0) { - logger.info(errorCounts, `Errors encountered:`); - } else { - logger.info(`There was no error encountered.`); + if (sum(Object.values(knownErrorCounts)) > 0) { + logger.info(knownErrorCounts, `Known errors encountered:`); + } + if (sum(Object.values(unknownErrorCounts)) > 0) { + logger.info(unknownErrorCounts, `Unknown errors encountered:`); } } @@ -182,8 +185,8 @@ class SessionHistory { return unique(this.getErrors(errorFilter)); } - public getErrorCounts() { - return toCountsFromArray(this.getErrors()); + public getErrorCounts(errorFilter: EventFilter = () => true) { + return toCountsFromArray(this.getErrors(errorFilter)); } } diff --git a/src/models/sessions/SessionHistoryBuilder.ts b/src/models/sessions/SessionHistoryBuilder.ts index ffb047e5..85fb6c80 100644 --- a/src/models/sessions/SessionHistoryBuilder.ts +++ b/src/models/sessions/SessionHistoryBuilder.ts @@ -67,7 +67,7 @@ class SessionHistoryBuilder { const errorCount = session.getErrors().length; if (errorCount > 1) { const sessionStartLine = session.getLogs()[0].line; - logger.warn(`Invalid session [@${sessionStartLine}] with ${errorCount} errors found (there should only be one)`); + logger.warn(`Invalid session [${session.getStartTime()} @${sessionStartLine}] with ${errorCount} > 1 errors found`); return; }