Merge branch 'master'

This commit is contained in:
emelko
2018-08-31 00:36:19 +02:00
parent 5296a9c6ee
commit 3ff7dd7340
14 changed files with 1359 additions and 706 deletions
+30 -4
View File
@@ -2,7 +2,8 @@ import Realm from 'realm'
import { LocalDate, ChronoUnit } from 'js-joda'
import {
cycleWithTempAndNoMucusShift,
cycleWithFhm,
cycleWithFhmMucus,
cycleWithFhmCervix,
longAndComplicatedCycle
} from './fixtures'
@@ -179,9 +180,9 @@ function getCycleDay(localDate) {
return db.objectForPrimaryKey('CycleDay', localDate)
}
function fillWithDummyData() {
function fillWithMucusDummyData() {
const dummyCycles = [
cycleWithFhm,
cycleWithFhmMucus,
longAndComplicatedCycle,
cycleWithTempAndNoMucusShift
]
@@ -204,6 +205,30 @@ function fillWithDummyData() {
})
}
function fillWithCervixDummyData() {
const dummyCycles = [
cycleWithFhmCervix
]
db.write(() => {
db.deleteAll()
dummyCycles.forEach(cycle => {
cycle.forEach(day => {
const existing = getCycleDay(day.date)
if (existing) {
Object.keys(day).forEach(key => {
if (key === 'date') return
existing[key] = day[key]
})
} else {
db.create('CycleDay', day)
}
})
})
})
}
function deleteAll() {
db.write(() => {
db.deleteAll()
@@ -266,7 +291,8 @@ export {
bleedingDaysSortedByDate,
temperatureDaysSortedByDate,
cycleDaysSortedByDate,
fillWithDummyData,
fillWithMucusDummyData,
fillWithCervixDummyData,
deleteAll,
getPreviousTemperature,
getCycleDay,