Introduce facade for sympto
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { detectTemperatureShift } from './sympto/temperature'
|
||||
import getTemperatureStatus from './sympto/temperature'
|
||||
import cycleModule from './cycle'
|
||||
|
||||
const getLastMensesStart = cycleModule().getLastMensesStart
|
||||
@@ -10,7 +10,7 @@ function getTemperatureFertilityStatus(targetDateString) {
|
||||
const previousTemperaturesInCycle = getPreviousTemperaturesInCycle(targetDateString, lastMensesStart)
|
||||
// we get temps with latest first, but sympto module expects latest last
|
||||
previousTemperaturesInCycle.reverse()
|
||||
const status = detectTemperatureShift(previousTemperaturesInCycle)
|
||||
const status = getTemperatureStatus(previousTemperaturesInCycle)
|
||||
return formatStatusForApp(status)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import getTemperatureStatus from './temperature'
|
||||
import getMucusStatus from './mucus'
|
||||
|
||||
export default function (cycleDays) {
|
||||
const temperatureStatus = getTemperatureStatus(cycleDays)
|
||||
const mucusStatus = getMucusStatus(cycleDays)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
function detectTemperatureShift(temperaturesOfCycle) {
|
||||
export default function getTemperatureStatus(temperaturesOfCycle) {
|
||||
// sensiplan rounds temps to the nearest 0.05
|
||||
const tempValues = temperaturesOfCycle.map(val => rounded(val, 0.05))
|
||||
|
||||
@@ -25,7 +25,7 @@ function detectTemperatureShift(temperaturesOfCycle) {
|
||||
if (temp <= ltl) return acc
|
||||
|
||||
const checkResult = checkIfFirstHighMeasurement(temp, i, tempValues, ltl)
|
||||
// if we don't have a winner, keep going
|
||||
// if we don't have a winner, keep move on to the next candidates
|
||||
if (!checkResult.isFirstHighMeasurement) return acc
|
||||
|
||||
// if we do, remember the details and start collecting the high level temps
|
||||
@@ -115,8 +115,4 @@ function secondOrThirdTempIsAtOrBelowLtl(nextTemps, ltl) {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
detectTemperatureShift
|
||||
}
|
||||
Reference in New Issue
Block a user