Replacing mucus default with secondarySymptom

This commit is contained in:
emelko
2018-09-05 15:29:32 +02:00
parent 1c2c45f8c6
commit 20dc238ea4
2 changed files with 14 additions and 7 deletions
+4 -1
View File
@@ -16,7 +16,10 @@ export default function getSymptoThermalStatus(cycleInfo) {
// if there was no first higher measurement in the previous cycle,
// no infertile pre-ovulatory phase may be assumed
if (previousCycle) {
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
const statusForLast = getSymptoThermalStatus({
cycle: previousCycle,
secondarySymptom: secondarySymptom
})
if (statusForLast.temperatureShift) {
const preOvuPhase = getPreOvulatoryPhase(
cycle,
+9 -5
View File
@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) {
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
return d.date <= preOvuEndDate
})
const preOvulatoryDays = getDaysUntilFertileMucus(maybePreOvuDays)
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays)
// if mucus occurs on the 1st cycle day, there is no pre-ovu phase
if (!preOvulatoryDays.length) return null
@@ -34,13 +34,17 @@ export default function(cycle, previousCycles) {
}
}
function getDaysUntilFertileMucus(days) {
const firstFertileMucusDayIndex = days.findIndex(day => {
function getDaysUntilFertileSecondarySymptom(days, secondarySymptom) {
const firstFertileSecondarySymptomDayIndex = days.findIndex(day => {
if (secondarySymptom === 'mucus') {
return day.mucus && day.mucus.value > 1
} else if (secondarySymptom === 'cervix') {
return day.cervix && !day.cervix.isClosedAndHard
}
})
if (firstFertileMucusDayIndex > -1) {
return days.slice(0, firstFertileMucusDayIndex)
if (firstFertileSecondarySymptomDayIndex > -1) {
return days.slice(0, firstFertileSecondarySymptomDayIndex)
}
return days
}