@@ -2,6 +2,7 @@ import { WEEKDAYS, WORKDAYS } from '../../constants/times';
22import logger from '../../logger' ;
33import { VersionedData , Weekday } from '../../types' ;
44import { toCountsFromArray , unique } from '../../utils/array' ;
5+ import { isKnownEvent } from '../../utils/event' ;
56import { formatDateForFilename , getWeekday } from '../../utils/locale' ;
67import { sum } from '../../utils/math' ;
78import 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
0 commit comments