Merge branch '95-bug-ignore-mucus-values-in-irrelevant-phase' into 'master'
Resolve "bug: ignore mucus values in irrelevant phase" Closes #95 See merge request bloodyhealth/drip!42
This commit is contained in:
+9
-4
@@ -1,10 +1,15 @@
|
||||
export default function (cycleDays, tempEvalEndIndex) {
|
||||
const mucusDays = cycleDays.filter(day => day.mucus && !day.mucus.exclude)
|
||||
const bestQuality = Math.max(...mucusDays.map(day => day.mucus.value))
|
||||
let currentBestQuality = 0
|
||||
|
||||
for (let i = 0; i < mucusDays.length; i++) {
|
||||
const day = mucusDays[i]
|
||||
if (day.mucus.value !== bestQuality) continue
|
||||
|
||||
if (day.mucus.value > currentBestQuality) {
|
||||
currentBestQuality = day.mucus.value
|
||||
}
|
||||
|
||||
if (day.mucus.value !== currentBestQuality) continue
|
||||
|
||||
// the three following days must be of lower quality
|
||||
// AND no best quality day may occur until temperature evaluation has
|
||||
@@ -13,7 +18,7 @@ export default function (cycleDays, tempEvalEndIndex) {
|
||||
if (threeFollowingDays.length < 3) continue
|
||||
|
||||
const bestQualityOccursIn3FollowingDays = threeFollowingDays.some(day => {
|
||||
return day.mucus.value >= bestQuality
|
||||
return day.mucus.value >= currentBestQuality
|
||||
})
|
||||
if (bestQualityOccursIn3FollowingDays) continue
|
||||
|
||||
@@ -23,7 +28,7 @@ export default function (cycleDays, tempEvalEndIndex) {
|
||||
.filter(day => day.mucus && !day.mucus.exclude)
|
||||
|
||||
const noBestQualityUntilEndOfTempEval = relevantDays.every(day => {
|
||||
return day.mucus.value < bestQuality
|
||||
return day.mucus.value < currentBestQuality
|
||||
})
|
||||
|
||||
if (noBestQualityUntilEndOfTempEval) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import periodInfo from '../lib/period-length'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe.only('getPeriodLengthStats', () => {
|
||||
describe('getPeriodLengthStats', () => {
|
||||
it('works for a simple odd-numbered array', () => {
|
||||
const periodLengths = [99, 5, 1, 2, 100]
|
||||
const result = periodInfo(periodLengths)
|
||||
|
||||
@@ -298,4 +298,27 @@ export const mucusPeakSlightlyBeforeTempShift = [
|
||||
{ date: '2018-06-20', temperature: 36.75, mucus: 1},
|
||||
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
|
||||
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
|
||||
export const highestMucusQualityAfterEndOfEval = [
|
||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.65 },
|
||||
{ date: '2018-06-04', temperature: 36.6 },
|
||||
{ date: '2018-06-07', temperature: 36.4, mucus: 1 },
|
||||
{ date: '2018-06-08', temperature: 36.35, mucus: 2},
|
||||
{ date: '2018-06-09', temperature: 36.4, mucus: 2},
|
||||
{ date: '2018-06-10', temperature: 36.45, mucus: 2},
|
||||
{ date: '2018-06-11', temperature: 36.4, mucus: 2},
|
||||
{ date: '2018-06-12', temperature: 36.45, mucus: 2},
|
||||
{ date: '2018-06-13', temperature: 36.45, mucus: 3},
|
||||
{ date: '2018-06-14', temperature: 36.55, mucus: 2},
|
||||
{ date: '2018-06-15', temperature: 36.6, mucus: 2},
|
||||
{ date: '2018-06-16', temperature: 36.6, mucus: 2},
|
||||
{ date: '2018-06-17', temperature: 36.55, mucus: 2},
|
||||
{ date: '2018-06-18', temperature: 36.6, mucus: 1},
|
||||
{ date: '2018-06-19', temperature: 36.7, mucus: 4},
|
||||
{ date: '2018-06-20', temperature: 36.75, mucus: 1},
|
||||
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
|
||||
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
|
||||
].map(convertToSymptoFormat)
|
||||
@@ -17,7 +17,8 @@ import {
|
||||
mucusPeakTwoDaysBeforeFhm,
|
||||
fhmOnDay12,
|
||||
fhmOnDay15,
|
||||
mucusPeakSlightlyBeforeTempShift
|
||||
mucusPeakSlightlyBeforeTempShift,
|
||||
highestMucusQualityAfterEndOfEval
|
||||
} from './fixtures'
|
||||
|
||||
const expect = chai.expect
|
||||
@@ -360,6 +361,40 @@ describe('sympto', () => {
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
|
||||
it('with highest quality after end of eval', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: highestMucusQualityAfterEndOfEval,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).to.be.an('object')
|
||||
|
||||
expect(Object.keys(status.phases).length).to.eql(3)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-05' },
|
||||
cycleDays: highestMucusQualityAfterEndOfEval
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
end: { date: '2018-06-17', time: '18:00' },
|
||||
cycleDays: highestMucusQualityAfterEndOfEval
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05' && date <= '2018-06-17'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-17',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: highestMucusQualityAfterEndOfEval
|
||||
.filter(({date}) => date >= '2018-06-17')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('applying the minus-8 rule', () => {
|
||||
|
||||
Reference in New Issue
Block a user