Cleanup
This commit is contained in:
+19
-11
@@ -14,9 +14,10 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
||||
|
||||
// if there was no first higher measurement in the previous cycle,
|
||||
// no infertile pre-ovulatory phase may be assumed
|
||||
if (previousCycles) {
|
||||
const lastCycle = previousCycles[previousCycles.length - 1]
|
||||
if (lastCycle && getSymptoThermalStatus({ cycle: lastCycle }).temperatureShift) {
|
||||
const lastCycle = previousCycles[previousCycles.length - 1]
|
||||
if (lastCycle) {
|
||||
const statusForLast = getSymptoThermalStatus({ cycle: lastCycle })
|
||||
if (statusForLast.temperatureShift) {
|
||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles)
|
||||
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
||||
status.assumeFertility = false
|
||||
@@ -33,7 +34,8 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
||||
|
||||
if (status.phases.preOvulatory) {
|
||||
const prePhase = status.phases.preOvulatory
|
||||
periPhase.start.date = LocalDate.parse(prePhase.end.date).plusDays(1).toString()
|
||||
const startDate = LocalDate.parse(prePhase.end.date).plusDays(1).toString()
|
||||
periPhase.start.date = startDate
|
||||
const lastPreDay = prePhase.cycleDays[prePhase.cycleDays.length - 1]
|
||||
periPhase.cycleDays = cycle.slice(cycle.indexOf(lastPreDay) + 1)
|
||||
} else {
|
||||
@@ -48,22 +50,28 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
||||
const mucusShift = getMucusShift(cycle, tempEvalEndIndex)
|
||||
if (!mucusShift.detected) return status
|
||||
|
||||
const periOvulatoryEnd =
|
||||
temperatureShift.evaluationCompleteDay.date > mucusShift.evaluationCompleteDay.date ?
|
||||
temperatureShift.evaluationCompleteDay : mucusShift.evaluationCompleteDay
|
||||
let periOvulatoryEnd
|
||||
const tempOver = temperatureShift.evaluationCompleteDay.date
|
||||
const mucusOver = mucusShift.evaluationCompleteDay.date
|
||||
|
||||
const prevPeriOvulatoryDays = periPhase.cycleDays
|
||||
const periOvulatoryEndIndex = prevPeriOvulatoryDays.indexOf(periOvulatoryEnd)
|
||||
if (tempOver > mucusOver) {
|
||||
periOvulatoryEnd = temperatureShift.evaluationCompleteDay
|
||||
} else {
|
||||
periOvulatoryEnd = mucusShift.evaluationCompleteDay
|
||||
}
|
||||
|
||||
const previousPeriDays = periPhase.cycleDays
|
||||
const previousPeriEndIndex = previousPeriDays.indexOf(periOvulatoryEnd)
|
||||
|
||||
status.phases.postOvulatory = {
|
||||
start: {
|
||||
date: periOvulatoryEnd.date,
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: prevPeriOvulatoryDays.slice(periOvulatoryEndIndex)
|
||||
cycleDays: previousPeriDays.slice(previousPeriEndIndex)
|
||||
}
|
||||
|
||||
periPhase.cycleDays = prevPeriOvulatoryDays.slice(0, periOvulatoryEndIndex + 1)
|
||||
periPhase.cycleDays = previousPeriDays.slice(0, previousPeriEndIndex + 1)
|
||||
periPhase.end = status.phases.postOvulatory.start
|
||||
|
||||
status.mucusShift = mucusShift
|
||||
|
||||
+3
-3
@@ -6,16 +6,16 @@ export default function (cycleDays, tempEvalEndIndex) {
|
||||
const day = mucusDays[i]
|
||||
if (day.mucus.value !== bestQuality) continue
|
||||
|
||||
// sensiplan says the three following days must be of lower quality
|
||||
// the three following days must be of lower quality
|
||||
// AND no best quality day may occur until temperature evaluation has
|
||||
// been completed
|
||||
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
|
||||
if (threeFollowingDays.length < 3) continue
|
||||
|
||||
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => {
|
||||
const bestQualityOccursIn3FollowingDays = threeFollowingDays.some(day => {
|
||||
return day.mucus.value >= bestQuality
|
||||
})
|
||||
if (bestQualityOccurringIn3FollowingDays) continue
|
||||
if (bestQualityOccursIn3FollowingDays) continue
|
||||
|
||||
const cycleDayIndex = cycleDays.indexOf(day)
|
||||
const relevantDays = cycleDays
|
||||
|
||||
@@ -23,11 +23,11 @@ export default function (cycleDays) {
|
||||
const temp = temperatureDays[i].temp
|
||||
if (temp <= ltl) continue
|
||||
|
||||
const checkResult = checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl)
|
||||
const shift = checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl)
|
||||
|
||||
if (checkResult.detected) {
|
||||
checkResult.firstHighMeasurementDay = temperatureDays[i].originalCycleDay
|
||||
return checkResult
|
||||
if (shift.detected) {
|
||||
shift.firstHighMeasurementDay = temperatureDays[i].originalCycleDay
|
||||
return shift
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user