Add more tests for combinations of fhm and mucus peak
This commit is contained in:
+8
-6
@@ -12,23 +12,25 @@ export default function (cycleDays, tempEvalEndIndex) {
|
||||
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
|
||||
if (threeFollowingDays.length < 3) continue
|
||||
|
||||
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => day.mucus.value >= bestQuality)
|
||||
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => {
|
||||
return day.mucus.value >= bestQuality
|
||||
})
|
||||
if (bestQualityOccurringIn3FollowingDays) continue
|
||||
|
||||
// FIXME mucus peak can be same day as first higher measurement
|
||||
const cycleDayIndex = cycleDays.indexOf(day)
|
||||
const relevantDays = cycleDays
|
||||
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
|
||||
.filter(day => day.mucus && !day.mucus.exclude)
|
||||
|
||||
const evaluationCompleteDay = relevantDays.length > 3 ?
|
||||
relevantDays[relevantDays.length - 1] : threeFollowingDays[threeFollowingDays.length - 1]
|
||||
const noBestQualityUntilEndOfTempEval = relevantDays.every(day => {
|
||||
return day.mucus.value < bestQuality
|
||||
})
|
||||
|
||||
if (relevantDays.every(day => day.mucus.value < bestQuality)) {
|
||||
if (noBestQualityUntilEndOfTempEval) {
|
||||
return {
|
||||
detected: true,
|
||||
mucusPeak: day,
|
||||
evaluationCompleteDay
|
||||
evaluationCompleteDay: threeFollowingDays[threeFollowingDays.length - 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user