Skip to content
Snippets Groups Projects
Commit 21dba527 authored by emelko's avatar emelko
Browse files

Renaming for more precision

parent 1b0d04df
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment