From 17bb23fd917770e94024cb8d6049c110746e50da Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Thu, 27 Sep 2018 19:29:26 +0200 Subject: [PATCH 1/2] Revert early return, fixes gaps in LTL line --- assets/drip_drip.svg | 17 +++++++++++++++++ assets/home-circle.js | 16 ++++++++++++++++ components/chart/chart.js | 29 ++++++++++++++++------------- 3 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 assets/drip_drip.svg create mode 100644 assets/home-circle.js diff --git a/assets/drip_drip.svg b/assets/drip_drip.svg new file mode 100644 index 0000000..2ec99a2 --- /dev/null +++ b/assets/drip_drip.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/assets/home-circle.js b/assets/home-circle.js new file mode 100644 index 0000000..f8c9bc5 --- /dev/null +++ b/assets/home-circle.js @@ -0,0 +1,16 @@ +import React from 'react' +import Svg, { G, Path } from 'react-native-svg' + +export default function HomeCycleIcon() { + return ( + + + + + + + ) +} \ No newline at end of file diff --git a/components/chart/chart.js b/components/chart/chart.js index 97717df..1595a2d 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -106,31 +106,34 @@ export default class CycleChart extends Component { const columns = xAxisDates.map(dateString => { const column = { dateString } const cycleDay = getCycleDay(dateString) - if (!cycleDay) return column + let symptoms = {} - const symptoms = chartSymptoms.reduce((acc, symptom) => { - if (symptom === 'bleeding' || + if (cycleDay) { + symptoms = chartSymptoms.reduce((acc, symptom) => { + if (symptom === 'bleeding' || symptom === 'temperature' || symptom === 'mucus' || symptom === 'desire' || symptom === 'note' - ) { - acc[symptom] = cycleDay[symptom] && cycleDay[symptom].value - } else if (symptom === 'cervix') { - acc.cervix = cycleDay.cervix && + ) { + acc[symptom] = cycleDay[symptom] && cycleDay[symptom].value + } else if (symptom === 'cervix') { + acc.cervix = cycleDay.cervix && (cycleDay.cervix.opening + cycleDay.cervix.firmness) - } else if (symptom === 'sex') { + } else if (symptom === 'sex') { // solo = 1 + partner = 2 acc.sex = cycleDay.sex && (cycleDay.sex.solo + 2 * cycleDay.sex.partner) } else if (symptom === 'pain') { // is any pain documented? - acc.pain = cycleDay.pain && + acc.pain = cycleDay.pain && Object.values(cycleDay.pain).some(x => x === true) - } - acc[`${symptom}Exclude`] = cycleDay[symptom] && cycleDay[symptom].exclude - return acc - }, {}) + } + acc[`${symptom}Exclude`] = cycleDay[symptom] && cycleDay[symptom].exclude + return acc + }, {}) + + } const temp = symptoms.temperature if (temp) { From 61275e83a0921f4d3232d03a53d61cd1810a8afd Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Fri, 28 Sep 2018 20:29:09 +0200 Subject: [PATCH 2/2] Ignore temp drop after 3 regular high temps --- components/chart/chart.js | 4 ++-- lib/sympto/temperature.js | 2 +- test/sympto/temperature.spec.js | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/components/chart/chart.js b/components/chart/chart.js index 1595a2d..8ea7f31 100644 --- a/components/chart/chart.js +++ b/components/chart/chart.js @@ -122,9 +122,9 @@ export default class CycleChart extends Component { (cycleDay.cervix.opening + cycleDay.cervix.firmness) } else if (symptom === 'sex') { // solo = 1 + partner = 2 - acc.sex = cycleDay.sex && + acc.sex = cycleDay.sex && (cycleDay.sex.solo + 2 * cycleDay.sex.partner) - } else if (symptom === 'pain') { + } else if (symptom === 'pain') { // is any pain documented? acc.pain = cycleDay.pain && Object.values(cycleDay.pain).some(x => x === true) diff --git a/lib/sympto/temperature.js b/lib/sympto/temperature.js index fb380b5..d738ba3 100644 --- a/lib/sympto/temperature.js +++ b/lib/sympto/temperature.js @@ -42,7 +42,7 @@ function checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl) { const nextDaysAfterPotentialFhm = temperatureDays.slice(i + 1, i + 4) return ( - getResultForRegularRule(nextDaysAfterPotentialFhm, ltl)) || + getResultForRegularRule(nextDaysAfterPotentialFhm.slice(0, 2), ltl)) || getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) || getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) || { detected: false } diff --git a/test/sympto/temperature.spec.js b/test/sympto/temperature.spec.js index ce7e6c1..0f4c782 100644 --- a/test/sympto/temperature.spec.js +++ b/test/sympto/temperature.spec.js @@ -40,6 +40,26 @@ describe('sympto', () => { }) }) + it('detects temperature shift correctly with drop after third high temp', () => { + const tempShift = + [36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8, 36.4] + .map(turnIntoCycleDayObject) + const status = getTemperatureStatus(tempShift) + expect(status).to.eql({ + detected: true, + ltl: 36.6, + firstHighMeasurementDay: { + date: 7, + temperature: { value: 36.8 } + }, + evaluationCompleteDay: { + date: 9, + temperature: { value: 36.8 } + }, + rule: 0 + }) + }) + it('detects no temperature shift when there are no 6 low temps', () => { const tempShift = [36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8] .map(turnIntoCycleDayObject)