Make previousCycle explicit in signature
This commit is contained in:
+5
-6
@@ -4,8 +4,8 @@ import getPreOvulatoryPhase from './pre-ovulatory'
|
||||
import { LocalDate } from 'js-joda'
|
||||
import assert from 'assert'
|
||||
|
||||
export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
|
||||
throwIfArgsAreNotInRequiredFormat([cycle, ...previousCycles])
|
||||
export default function getSymptoThermalStatus({ cycle, previousCycle, earlierCycles = [] }) {
|
||||
throwIfArgsAreNotInRequiredFormat([cycle, ...earlierCycles])
|
||||
|
||||
const status = {
|
||||
assumeFertility: true,
|
||||
@@ -14,11 +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
|
||||
const lastCycle = previousCycles[previousCycles.length - 1]
|
||||
if (lastCycle) {
|
||||
const statusForLast = getSymptoThermalStatus({ cycle: lastCycle })
|
||||
if (previousCycle) {
|
||||
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
|
||||
if (statusForLast.temperatureShift) {
|
||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles)
|
||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, [previousCycle, ...earlierCycles])
|
||||
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
||||
status.assumeFertility = false
|
||||
return status
|
||||
|
||||
Reference in New Issue
Block a user