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
|
||||
|
||||
Reference in New Issue
Block a user