Use new smpto module in day view

This commit is contained in:
Julia Friesel
2018-07-13 09:10:00 +02:00
parent de2233f998
commit 8a8b131064
3 changed files with 35 additions and 27 deletions
+14 -2
View File
@@ -4,16 +4,20 @@ const LocalDate = joda.LocalDate
export default function config(opts) {
let bleedingDaysSortedByDate
let temperatureDaysSortedByDate
let cycleDaysSortedByDate
let maxBreakInBleeding
if (!opts) {
// we only want to require (and run) the db module when not running the tests
// we only want to require (and run) the db module
// when not running the tests
bleedingDaysSortedByDate = require('../db').bleedingDaysSortedByDate
temperatureDaysSortedByDate = require('../db').temperatureDaysSortedByDate
cycleDaysSortedByDate = require('../db').cycleDaysSortedByDate
maxBreakInBleeding = 1
} else {
bleedingDaysSortedByDate = opts.bleedingDaysSortedByDate || []
temperatureDaysSortedByDate = opts.temperatureDaysSortedByDate || []
cycleDaysSortedByDate = opts.cycleDaysSortedByDate || []
maxBreakInBleeding = opts.maxBreakInBleeding || 1
}
@@ -67,9 +71,17 @@ export default function config(opts) {
.map(day => day.temperature.value)
}
function getCycleDaysBeforeDay(targetDateString) {
const firstCycleDay = getLastMensesStart(targetDateString)
return cycleDaysSortedByDate.filter(({date}) => {
return date >= firstCycleDay.date && date <= targetDateString
})
}
return {
getCycleDayNumber,
getLastMensesStart,
getPreviousTemperaturesInCycle
getPreviousTemperaturesInCycle,
getCycleDaysBeforeDay
}
}