Renaming for more precision

This commit is contained in:
emelko
2018-09-09 16:35:16 +02:00
parent 1b0d04dfc0
commit 21dba52753
+18 -18
View File
@@ -39,18 +39,18 @@ function checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl) {
if (i > temperatureDays.length - 3) { if (i > temperatureDays.length - 3) {
return { detected: false } return { detected: false }
} }
const nextDaysAfterFhm = temperatureDays.slice(i + 1, i + 4) const nextDaysAfterPotentialFhm = temperatureDays.slice(i + 1, i + 4)
return ( return (
getResultForRegularRule(nextDaysAfterFhm, ltl)) || getResultForRegularRule(nextDaysAfterPotentialFhm, ltl)) ||
getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) || getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) || getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
{ detected: false } { detected: false }
} }
function getResultForRegularRule(nextDaysAfterFhm, ltl) { function getResultForRegularRule(nextDaysAfterPotentialFhm, ltl) {
if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
const thirdDay = nextDaysAfterFhm[1] const thirdDay = nextDaysAfterPotentialFhm[1]
if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false
return { return {
detected: true, detected: true,
@@ -60,10 +60,10 @@ function getResultForRegularRule(nextDaysAfterFhm, ltl) {
} }
} }
function getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) { function getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) {
if (nextDaysAfterFhm.length < 3) return false if (nextDaysAfterPotentialFhm.length < 3) return false
if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
const fourthDay = nextDaysAfterFhm[2] const fourthDay = nextDaysAfterPotentialFhm[2]
if (fourthDay.temp <= ltl) return false if (fourthDay.temp <= ltl) return false
return { return {
detected: true, detected: true,
@@ -73,10 +73,10 @@ function getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) {
} }
} }
function getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) { function getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) {
if (nextDaysAfterFhm.length < 3) return false if (nextDaysAfterPotentialFhm.length < 3) return false
if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl)) { if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl)) {
const fourthDay = nextDaysAfterFhm[2] const fourthDay = nextDaysAfterPotentialFhm[2]
if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) { if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) {
return { return {
detected: true, detected: true,
@@ -89,9 +89,9 @@ function getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) {
return false return false
} }
function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl) { function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl) {
const secondIsLow = nextDaysAfterFhm[0].temp <= ltl const secondIsLow = nextDaysAfterPotentialFhm[0].temp <= ltl
const thirdIsLow = nextDaysAfterFhm[1].temp <= ltl const thirdIsLow = nextDaysAfterPotentialFhm[1].temp <= ltl
if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) { if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) {
return true return true
} else { } else {