From abee426337294d046d23a949899cc5cf6d39162b Mon Sep 17 00:00:00 2001 From: emelko Date: Wed, 5 Sep 2018 15:30:38 +0200 Subject: [PATCH] Renaming nextDays in nextDaysAfterFhm when calculating temperatureShift --- lib/sympto/temperature.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/sympto/temperature.js b/lib/sympto/temperature.js index 387cd63..418757b 100644 --- a/lib/sympto/temperature.js +++ b/lib/sympto/temperature.js @@ -39,18 +39,18 @@ function checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl) { if (i > temperatureDays.length - 3) { return { detected: false } } - const nextDays = temperatureDays.slice(i + 1, i + 4) + const nextDaysAfterFhm = temperatureDays.slice(i + 1, i + 4) return ( - getResultForRegularRule(nextDays, ltl)) || - getResultForFirstExceptionRule(nextDays, ltl) || - getResultForSecondExceptionRule(nextDays, ltl) || + getResultForRegularRule(nextDaysAfterFhm, ltl)) || + getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) || + getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) || { detected: false } } -function getResultForRegularRule(nextDays, ltl) { - if (!nextDays.every(day => day.temp > ltl)) return false - const thirdDay = nextDays[1] +function getResultForRegularRule(nextDaysAfterFhm, ltl) { + if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false + const thirdDay = nextDaysAfterFhm[1] if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false return { detected: true, @@ -60,10 +60,10 @@ function getResultForRegularRule(nextDays, ltl) { } } -function getResultForFirstExceptionRule(nextDays, ltl) { - if (nextDays.length < 3) return false - if (!nextDays.every(day => day.temp > ltl)) return false - const fourthDay = nextDays[2] +function getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) { + if (nextDaysAfterFhm.length < 3) return false + if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false + const fourthDay = nextDaysAfterFhm[2] if (fourthDay.temp <= ltl) return false return { detected: true, @@ -73,10 +73,10 @@ function getResultForFirstExceptionRule(nextDays, ltl) { } } -function getResultForSecondExceptionRule(nextDays, ltl) { - if (nextDays.length < 3) return false - if (secondOrThirdTempIsAtOrBelowLtl(nextDays, ltl)) { - const fourthDay = nextDays[2] +function getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) { + if (nextDaysAfterFhm.length < 3) return false + if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl)) { + const fourthDay = nextDaysAfterFhm[2] if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) { return { detected: true, @@ -89,9 +89,9 @@ function getResultForSecondExceptionRule(nextDays, ltl) { return false } -function secondOrThirdTempIsAtOrBelowLtl(nextDays, ltl) { - const secondIsLow = nextDays[0].temp <= ltl - const thirdIsLow = nextDays[1].temp <= ltl +function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl) { + const secondIsLow = nextDaysAfterFhm[0].temp <= ltl + const thirdIsLow = nextDaysAfterFhm[1].temp <= ltl if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) { return true } else {