Cleanup
This commit is contained in:
@@ -48,6 +48,6 @@
|
|||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"react/prop-types": 0,
|
"react/prop-types": 0,
|
||||||
"max-len": "warn"
|
"max-len": [1, {"ignoreStrings": true}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-3
@@ -1,5 +1,7 @@
|
|||||||
const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
export const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
||||||
|
|
||||||
export {
|
export const fertilityStatus = {
|
||||||
bleeding
|
fertile: 'fertile',
|
||||||
|
infertile: 'infertile',
|
||||||
|
unknown: 'We cannot show any cycle information because no menses has been entered'
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import getFertilityStatus from './sympto'
|
import getFertilityStatus from './sympto'
|
||||||
import cycleModule from './cycle'
|
import cycleModule from './cycle'
|
||||||
|
import { fertilityStatus } from '../labels/labels'
|
||||||
|
|
||||||
const { getCycleDaysBeforeDay, getPreviousCycles } = cycleModule()
|
const { getCycleDaysBeforeDay, getPreviousCycles } = cycleModule()
|
||||||
|
|
||||||
export default function (dateString) {
|
export default function (dateString) {
|
||||||
const cycle = getCycleDaysBeforeDay(dateString)
|
const cycle = getCycleDaysBeforeDay(dateString)
|
||||||
if (!cycle) return `We cannot show any cycle information because no menses has been entered`
|
if (!cycle) return fertilityStatus.unknown
|
||||||
|
|
||||||
// we get earliest last, but sympto wants earliest first
|
// we get earliest last, but sympto wants earliest first
|
||||||
cycle.reverse()
|
cycle.reverse()
|
||||||
@@ -18,5 +19,9 @@ export default function (dateString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatStatusForApp(status) {
|
function formatStatusForApp(status) {
|
||||||
return status.assumeFertility ? 'fertile' : 'infertile'
|
if (status.assumeFertility) {
|
||||||
|
return fertilityStatus.fertile
|
||||||
|
} else {
|
||||||
|
return fertilityStatus.infertile
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+19
-11
@@ -14,9 +14,10 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
|||||||
|
|
||||||
// if there was no first higher measurement in the previous cycle,
|
// if there was no first higher measurement in the previous cycle,
|
||||||
// no infertile pre-ovulatory phase may be assumed
|
// no infertile pre-ovulatory phase may be assumed
|
||||||
if (previousCycles) {
|
const lastCycle = previousCycles[previousCycles.length - 1]
|
||||||
const lastCycle = previousCycles[previousCycles.length - 1]
|
if (lastCycle) {
|
||||||
if (lastCycle && getSymptoThermalStatus({ cycle: lastCycle }).temperatureShift) {
|
const statusForLast = getSymptoThermalStatus({ cycle: lastCycle })
|
||||||
|
if (statusForLast.temperatureShift) {
|
||||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles)
|
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles)
|
||||||
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
||||||
status.assumeFertility = false
|
status.assumeFertility = false
|
||||||
@@ -33,7 +34,8 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
|||||||
|
|
||||||
if (status.phases.preOvulatory) {
|
if (status.phases.preOvulatory) {
|
||||||
const prePhase = 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]
|
const lastPreDay = prePhase.cycleDays[prePhase.cycleDays.length - 1]
|
||||||
periPhase.cycleDays = cycle.slice(cycle.indexOf(lastPreDay) + 1)
|
periPhase.cycleDays = cycle.slice(cycle.indexOf(lastPreDay) + 1)
|
||||||
} else {
|
} else {
|
||||||
@@ -48,22 +50,28 @@ export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
|||||||
const mucusShift = getMucusShift(cycle, tempEvalEndIndex)
|
const mucusShift = getMucusShift(cycle, tempEvalEndIndex)
|
||||||
if (!mucusShift.detected) return status
|
if (!mucusShift.detected) return status
|
||||||
|
|
||||||
const periOvulatoryEnd =
|
let periOvulatoryEnd
|
||||||
temperatureShift.evaluationCompleteDay.date > mucusShift.evaluationCompleteDay.date ?
|
const tempOver = temperatureShift.evaluationCompleteDay.date
|
||||||
temperatureShift.evaluationCompleteDay : mucusShift.evaluationCompleteDay
|
const mucusOver = mucusShift.evaluationCompleteDay.date
|
||||||
|
|
||||||
const prevPeriOvulatoryDays = periPhase.cycleDays
|
if (tempOver > mucusOver) {
|
||||||
const periOvulatoryEndIndex = prevPeriOvulatoryDays.indexOf(periOvulatoryEnd)
|
periOvulatoryEnd = temperatureShift.evaluationCompleteDay
|
||||||
|
} else {
|
||||||
|
periOvulatoryEnd = mucusShift.evaluationCompleteDay
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousPeriDays = periPhase.cycleDays
|
||||||
|
const previousPeriEndIndex = previousPeriDays.indexOf(periOvulatoryEnd)
|
||||||
|
|
||||||
status.phases.postOvulatory = {
|
status.phases.postOvulatory = {
|
||||||
start: {
|
start: {
|
||||||
date: periOvulatoryEnd.date,
|
date: periOvulatoryEnd.date,
|
||||||
time: '18:00'
|
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
|
periPhase.end = status.phases.postOvulatory.start
|
||||||
|
|
||||||
status.mucusShift = mucusShift
|
status.mucusShift = mucusShift
|
||||||
|
|||||||
+3
-3
@@ -6,16 +6,16 @@ export default function (cycleDays, tempEvalEndIndex) {
|
|||||||
const day = mucusDays[i]
|
const day = mucusDays[i]
|
||||||
if (day.mucus.value !== bestQuality) continue
|
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
|
// AND no best quality day may occur until temperature evaluation has
|
||||||
// been completed
|
// been completed
|
||||||
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
|
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
|
||||||
if (threeFollowingDays.length < 3) continue
|
if (threeFollowingDays.length < 3) continue
|
||||||
|
|
||||||
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => {
|
const bestQualityOccursIn3FollowingDays = threeFollowingDays.some(day => {
|
||||||
return day.mucus.value >= bestQuality
|
return day.mucus.value >= bestQuality
|
||||||
})
|
})
|
||||||
if (bestQualityOccurringIn3FollowingDays) continue
|
if (bestQualityOccursIn3FollowingDays) continue
|
||||||
|
|
||||||
const cycleDayIndex = cycleDays.indexOf(day)
|
const cycleDayIndex = cycleDays.indexOf(day)
|
||||||
const relevantDays = cycleDays
|
const relevantDays = cycleDays
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ export default function (cycleDays) {
|
|||||||
const temp = temperatureDays[i].temp
|
const temp = temperatureDays[i].temp
|
||||||
if (temp <= ltl) continue
|
if (temp <= ltl) continue
|
||||||
|
|
||||||
const checkResult = checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl)
|
const shift = checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl)
|
||||||
|
|
||||||
if (checkResult.detected) {
|
if (shift.detected) {
|
||||||
checkResult.firstHighMeasurementDay = temperatureDays[i].originalCycleDay
|
shift.firstHighMeasurementDay = temperatureDays[i].originalCycleDay
|
||||||
return checkResult
|
return shift
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user