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) {
return { detected: false }
}
const nextDaysAfterFhm = temperatureDays.slice(i + 1, i + 4)
const nextDaysAfterPotentialFhm = temperatureDays.slice(i + 1, i + 4)
return (
getResultForRegularRule(nextDaysAfterFhm, ltl)) ||
getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) ||
getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) ||
getResultForRegularRule(nextDaysAfterPotentialFhm, ltl)) ||
getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
{ detected: false }
}
function getResultForRegularRule(nextDaysAfterFhm, ltl) {
if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false
const thirdDay = nextDaysAfterFhm[1]
function getResultForRegularRule(nextDaysAfterPotentialFhm, ltl) {
if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
const thirdDay = nextDaysAfterPotentialFhm[1]
if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false
return {
detected: true,
@@ -60,10 +60,10 @@ function getResultForRegularRule(nextDaysAfterFhm, ltl) {
}
}
function getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) {
if (nextDaysAfterFhm.length < 3) return false
if (!nextDaysAfterFhm.every(day => day.temp > ltl)) return false
const fourthDay = nextDaysAfterFhm[2]
function getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) {
if (nextDaysAfterPotentialFhm.length < 3) return false
if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
const fourthDay = nextDaysAfterPotentialFhm[2]
if (fourthDay.temp <= ltl) return false
return {
detected: true,
@@ -73,10 +73,10 @@ function getResultForFirstExceptionRule(nextDaysAfterFhm, ltl) {
}
}
function getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) {
if (nextDaysAfterFhm.length < 3) return false
if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl)) {
const fourthDay = nextDaysAfterFhm[2]
function getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) {
if (nextDaysAfterPotentialFhm.length < 3) return false
if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl)) {
const fourthDay = nextDaysAfterPotentialFhm[2]
if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) {
return {
detected: true,
@@ -89,9 +89,9 @@ function getResultForSecondExceptionRule(nextDaysAfterFhm, ltl) {
return false
}
function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterFhm, ltl) {
const secondIsLow = nextDaysAfterFhm[0].temp <= ltl
const thirdIsLow = nextDaysAfterFhm[1].temp <= ltl
function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl) {
const secondIsLow = nextDaysAfterPotentialFhm[0].temp <= ltl
const thirdIsLow = nextDaysAfterPotentialFhm[1].temp <= ltl
if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) {
return true
} else {