A bit more defensive programming

A bit more defensive programming as one bad (NaN) measurement of CurrentDt will kill all metrics for the entire session.
This commit is contained in:
Jaap van Ekris 2023-01-10 11:34:00 +01:00 committed by GitHub
parent 6623aa2f86
commit 062faa0190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -58,7 +58,7 @@ function createFlywheel (rowerSettings) {
reset()
function pushValue (dataPoint) {
if (dataPoint > rowerSettings.maximumStrokeTimeBeforePause || dataPoint < 0) {
if (isNaN(dataPoint) || dataPoint < 0 || dataPoint > rowerSettings.maximumStrokeTimeBeforePause) {
// This typicaly happends after a pause, we need to fix this as it throws off all time calculations
log.debug(`*** WARNING: currentDt of ${dataPoint} sec isn't between 0 and maximumStrokeTimeBeforePause (${rowerSettings.maximumStrokeTimeBeforePause} sec)`)
dataPoint = currentDt.clean()