Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
8a8b1310
Commit
8a8b1310
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Use new smpto module in day view
parent
de2233f9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/cycle-day.js
+11
-4
11 additions, 4 deletions
components/cycle-day.js
lib/cycle.js
+14
-2
14 additions, 2 deletions
lib/cycle.js
lib/sympto-adapter.js
+10
-21
10 additions, 21 deletions
lib/sympto-adapter.js
with
35 additions
and
27 deletions
components/cycle-day.js
+
11
−
4
View file @
8a8b1310
...
...
@@ -4,7 +4,7 @@ import {
Text
}
from
'
react-native
'
import
cycleModule
from
'
../lib/cycle
'
import
{
get
Temperature
FertilityStatus
}
from
'
../lib/sympto-adapter
'
import
getFertilityStatus
from
'
../lib/sympto-adapter
'
import
DayView
from
'
./cycle-day-overview
'
import
BleedingEditView
from
'
./bleeding
'
import
TemperatureEditView
from
'
./temperature
'
...
...
@@ -29,7 +29,7 @@ export default class Day extends Component {
render
()
{
const
cycleDayNumber
=
getCycleDayNumber
(
this
.
cycleDay
.
date
)
const
temperatureF
ertilityStatus
=
get
Temperature
FertilityStatus
(
this
.
cycleDay
.
date
)
const
f
ertilityStatus
=
getFertilityStatus
(
this
.
cycleDay
.
date
)
return
(
<
View
style
=
{
styles
.
cycleDayOuterView
}
>
<
View
style
=
{
styles
.
cycleDayDateView
}
>
...
...
@@ -38,8 +38,15 @@ export default class Day extends Component {
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
cycleDayNumberView
}
>
{
cycleDayNumber
&&
<
Text
style
=
{
styles
.
cycleDayNumber
}
>
Cycle
day
{
cycleDayNumber
}
<
/Text>
}
{
cycleDayNumber
&&
<
Text
style
=
{
styles
.
cycleDayNumber
}
>
Temperature
status
:
{
temperatureFertilityStatus
}
<
/Text>
}
{
cycleDayNumber
&&
<
Text
style
=
{
styles
.
cycleDayNumber
}
>
Cycle
day
{
cycleDayNumber
}
<
/Text>
}
{
cycleDayNumber
&&
<
Text
style
=
{
styles
.
cycleDayNumber
}
>
{
fertilityStatus
}
<
/Text>
}
<
/View
>
<
View
style
=
{
styles
.
cycleDaySymptomsView
}
>
{
...
...
This diff is collapsed.
Click to expand it.
lib/cycle.js
+
14
−
2
View file @
8a8b1310
...
...
@@ -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
}
}
This diff is collapsed.
Click to expand it.
lib/sympto-adapter.js
+
10
−
21
View file @
8a8b1310
import
get
Temperature
Status
from
'
./sympto
/temperature
'
import
get
Fertility
Status
from
'
./sympto
'
import
cycleModule
from
'
./cycle
'
const
getLastMensesStart
=
cycleModule
().
getLastMensesStart
const
getPreviousTemperaturesInCycle
=
cycleModule
().
getPreviousTemperaturesInCycle
const
{
getCycleDaysBeforeDay
}
=
cycleModule
()
export
default
function
(
dateString
)
{
// we get earliest last, but sympto wants earliest first
const
cycle
=
getCycleDaysBeforeDay
(
dateString
).
reverse
()
// const previousCycles = getPreviousCycles()
const
status
=
getFertilityStatus
({
cycle
})
function
getTemperatureFertilityStatus
(
targetDateString
)
{
const
lastMensesStart
=
getLastMensesStart
(
targetDateString
)
if
(
!
lastMensesStart
)
return
formatStatusForApp
({
detected
:
false
})
const
previousTemperaturesInCycle
=
getPreviousTemperaturesInCycle
(
targetDateString
,
lastMensesStart
)
// we get temps with latest first, but sympto module expects latest last
previousTemperaturesInCycle
.
reverse
()
const
status
=
getTemperatureStatus
(
previousTemperaturesInCycle
)
return
formatStatusForApp
(
status
)
}
function
formatStatusForApp
(
status
)
{
if
(
!
status
.
detected
)
return
'
fertile
'
const
dict
=
[
"
regular temperature
"
,
"
first exception
"
,
"
second exception
"
]
return
`infertile according to the
${
dict
[
status
.
rule
]}
rule`
}
export
{
getTemperatureFertilityStatus
const
fertileStatus
=
status
.
assumeFertility
?
'
fertile
'
:
'
infertile
'
return
`You are currently
${
fertileStatus
}
`
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment