Merge branch 'master'
This commit is contained in:
+26
-2
@@ -1,6 +1,9 @@
|
||||
function convertToSymptoFormat(val) {
|
||||
const sympto = { date: val.date }
|
||||
if (val.temperature) sympto.temperature = { value: val.temperature, exclude: false }
|
||||
if (val.temperature) sympto.temperature = {
|
||||
value: val.temperature,
|
||||
exclude: false
|
||||
}
|
||||
if (val.mucus) sympto.mucus = {
|
||||
value: val.mucus,
|
||||
exclude: false,
|
||||
@@ -11,7 +14,7 @@ function convertToSymptoFormat(val) {
|
||||
return sympto
|
||||
}
|
||||
|
||||
export const cycleWithFhm = [
|
||||
export const cycleWithFhmMucus = [
|
||||
{ date: '2018-07-01', bleeding: 2 },
|
||||
{ date: '2018-07-02', bleeding: 1 },
|
||||
{ date: '2018-07-06', temperature: 36.2},
|
||||
@@ -26,6 +29,27 @@ export const cycleWithFhm = [
|
||||
{ date: '2018-07-18', temperature: 36.9, mucus: 2 }
|
||||
].map(convertToSymptoFormat).reverse()
|
||||
|
||||
export const cycleWithFhmCervix = [
|
||||
{ date: '2018-08-01', bleeding: 2 },
|
||||
{ date: '2018-08-02', bleeding: 1 },
|
||||
{ date: '2018-08-03', bleeding: 0 },
|
||||
{ date: '2018-08-04', bleeding: 0 },
|
||||
{ date: '2018-08-05', temperature: 36.07 },
|
||||
{ date: '2018-08-06', temperature: 36.2 },
|
||||
{ date: '2018-08-07', temperature: 36.35 },
|
||||
{ date: '2018-08-08', temperature: 36.4 },
|
||||
{ date: '2018-08-09', temperature: 36.3 },
|
||||
{ date: '2018-08-10', temperature: 36.45 },
|
||||
{ date: '2018-08-11', temperature: 36.45 },
|
||||
{ date: '2018-08-12', temperature: 36.7, cervix: { isClosed: false, isHard: false } },
|
||||
{ date: '2018-08-13', temperature: 36.8, cervix: { isClosed: true, isHard: true } },
|
||||
{ date: '2018-08-14', temperature: 36.75, cervix: { isClosed: true, isHard: true } },
|
||||
{ date: '2018-08-15', temperature: 36.9, cervix: { isClosed: true, isHard: true } },
|
||||
{ date: '2018-08-16', temperature: 36.95, cervix: { isClosed: true, isHard: true } },
|
||||
{ date: '2018-08-17', temperature: 36.9, cervix: { isClosed: true, isHard: true } },
|
||||
{ date: '2018-08-18', temperature: 36.9, cervix: { isClosed: false, isHard: true } }
|
||||
].map(convertToSymptoFormat).reverse()
|
||||
|
||||
export const longAndComplicatedCycle = [
|
||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.65 },
|
||||
|
||||
+30
-4
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user