Renaming nextDays in nextDaysAfterFhm when calculating temperatureShift
This commit is contained in:
+18
-18
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user