Skip to content

Commit d3875f0

Browse files
committed
Differentiate between known/unknown errors in history summary.
1 parent e7e558f commit d3875f0

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "berlin-lea-performance-monitor",
3-
"version": "1.11.3",
3+
"version": "1.12.0",
44
"author": "David Leclerc",
55
"main": "./src/index.ts",
66
"scripts": {

src/models/sessions/SessionHistory.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { WEEKDAYS, WORKDAYS } from '../../constants/times';
22
import logger from '../../logger';
33
import { VersionedData, Weekday } from '../../types';
44
import { toCountsFromArray, unique } from '../../utils/array';
5+
import { isKnownEvent } from '../../utils/event';
56
import { formatDateForFilename, getWeekday } from '../../utils/locale';
67
import { sum } from '../../utils/math';
78
import TimeDuration from '../TimeDuration';
@@ -38,9 +39,10 @@ class SessionHistory {
3839
}
3940

4041
public summarize() {
41-
const errorCounts = this.getErrorCounts();
42-
const successTimes = this
43-
.getSuccesses()
42+
const knownErrorCounts = this.getErrorCounts(isKnownEvent);
43+
const unknownErrorCounts = this.getErrorCounts(err => !isKnownEvent(err));
44+
45+
const successTimes = this.getSuccesses()
4446
.map(session => formatDateForFilename(session.getEndTime()));
4547

4648
if (successTimes.length > 0) {
@@ -49,10 +51,11 @@ class SessionHistory {
4951
logger.info(`There was never an appointment available.`);
5052
}
5153

52-
if (sum(Object.values(errorCounts)) > 0) {
53-
logger.info(errorCounts, `Errors encountered:`);
54-
} else {
55-
logger.info(`There was no error encountered.`);
54+
if (sum(Object.values(knownErrorCounts)) > 0) {
55+
logger.info(knownErrorCounts, `Known errors encountered:`);
56+
}
57+
if (sum(Object.values(unknownErrorCounts)) > 0) {
58+
logger.info(unknownErrorCounts, `Unknown errors encountered:`);
5659
}
5760
}
5861

@@ -182,8 +185,8 @@ class SessionHistory {
182185
return unique(this.getErrors(errorFilter));
183186
}
184187

185-
public getErrorCounts() {
186-
return toCountsFromArray(this.getErrors());
188+
public getErrorCounts(errorFilter: EventFilter = () => true) {
189+
return toCountsFromArray(this.getErrors(errorFilter));
187190
}
188191
}
189192

src/models/sessions/SessionHistoryBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SessionHistoryBuilder {
6767
const errorCount = session.getErrors().length;
6868
if (errorCount > 1) {
6969
const sessionStartLine = session.getLogs()[0].line;
70-
logger.warn(`Invalid session [@${sessionStartLine}] with ${errorCount} errors found (there should only be one)`);
70+
logger.warn(`Invalid session [${session.getStartTime()} @${sessionStartLine}] with ${errorCount} > 1 errors found`);
7171
return;
7272
}
7373

0 commit comments

Comments
 (0)