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
9102bce7
Commit
9102bce7
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Return cycle phase starts
parent
836bea77
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/sympto/index.js
+18
-4
18 additions, 4 deletions
lib/sympto/index.js
test/sympto/index.spec.js
+13
-8
13 additions, 8 deletions
test/sympto/index.spec.js
with
31 additions
and
12 deletions
lib/sympto/index.js
+
18
−
4
View file @
9102bce7
...
@@ -2,18 +2,32 @@ import getTemperatureShift from './temperature'
...
@@ -2,18 +2,32 @@ import getTemperatureShift from './temperature'
import
getMucusShift
from
'
./mucus
'
import
getMucusShift
from
'
./mucus
'
export
default
function
(
cycleDays
)
{
export
default
function
(
cycleDays
)
{
const
assumeFertile
=
{
assumeFertility
:
true
}
const
assumeFertileStatus
=
{
assumeFertility
:
true
}
// TODO second phase calculation
if
(
cycleDays
.
length
)
assumeFertileStatus
.
phases
=
[
{
startDate
:
cycleDays
[
0
].
date
,
startTime
:
'
00:00
'
},
'
TODO
'
]
const
temperatureShift
=
getTemperatureShift
(
cycleDays
)
const
temperatureShift
=
getTemperatureShift
(
cycleDays
)
if
(
!
temperatureShift
.
detected
)
return
assumeFertile
if
(
!
temperatureShift
.
detected
)
return
assumeFertile
Status
const
tempEvalEndIndex
=
cycleDays
.
indexOf
(
temperatureShift
.
evaluationCompleteDay
)
const
tempEvalEndIndex
=
cycleDays
.
indexOf
(
temperatureShift
.
evaluationCompleteDay
)
const
mucusShift
=
getMucusShift
(
cycleDays
,
tempEvalEndIndex
)
const
mucusShift
=
getMucusShift
(
cycleDays
,
tempEvalEndIndex
)
if
(
!
mucusShift
.
detected
)
return
assumeFertile
if
(
!
mucusShift
.
detected
)
return
assumeFertileStatus
const
phase2
=
{
startDate
:
temperatureShift
.
evaluationCompleteDay
.
date
,
startTime
:
'
18:00
'
}
return
{
return
{
assumeFertility
:
false
,
assumeFertility
:
false
,
temperatureShift
,
temperatureShift
,
mucusShift
mucusShift
,
phases
:
assumeFertileStatus
.
phases
.
concat
(
phase2
)
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/sympto/index.spec.js
+
13
−
8
View file @
9102bce7
...
@@ -4,18 +4,18 @@ import getSensiplanStatus from '../../lib/sympto'
...
@@ -4,18 +4,18 @@ import getSensiplanStatus from '../../lib/sympto'
const
expect
=
chai
.
expect
const
expect
=
chai
.
expect
function
convertToSymptoFormat
(
val
,
i
)
{
function
convertToSymptoFormat
(
val
,
i
)
{
return
{
const
sympto
=
{
date
:
i
}
date
:
i
,
if
(
val
.
temperature
)
sympto
.
temperature
=
{
value
:
val
.
temperature
}
temperature
:
val
.
temperature
?
{
value
:
val
.
temperature
}
:
null
,
if
(
val
.
mucus
)
sympto
.
mucus
=
{
value
:
val
.
mucus
}
mucus
:
val
.
mucus
?
{
value
:
val
.
mucus
}
:
null
if
(
val
.
bleeding
)
sympto
.
bleeding
=
{
value
:
val
.
bleeding
}
}
return
sympto
}
}
describe
(
'
sympto
'
,
()
=>
{
describe
(
'
sympto
'
,
()
=>
{
describe
(
'
evaluating mucus and temperature shift together
'
,
()
=>
{
describe
(
'
evaluating mucus and temperature shift together
'
,
()
=>
{
it
(
'
reports fertile when mucus reaches best quality again within temperature evaluation phase
'
,
function
()
{
it
(
'
reports fertile when mucus reaches best quality again within temperature evaluation phase
'
,
function
()
{
const
values
=
[
const
values
=
[
{
temperature
:
36.6
},
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.6
},
...
@@ -48,6 +48,11 @@ describe('sympto', () => {
...
@@ -48,6 +48,11 @@ describe('sympto', () => {
const
status
=
getSensiplanStatus
(
temperatures
)
const
status
=
getSensiplanStatus
(
temperatures
)
expect
(
status
).
to
.
eql
({
expect
(
status
).
to
.
eql
({
assumeFertility
:
false
,
assumeFertility
:
false
,
phases
:
[
{
startDate
:
0
,
startTime
:
'
00:00
'
},
'
TODO
'
,
{
startDate
:
17
,
startTime
:
'
18:00
'
}
],
temperatureShift
:
{
temperatureShift
:
{
detected
:
true
,
detected
:
true
,
ltl
:
36.55
,
ltl
:
36.55
,
...
@@ -60,7 +65,7 @@ describe('sympto', () => {
...
@@ -60,7 +65,7 @@ describe('sympto', () => {
evaluationCompleteDay
:
{
evaluationCompleteDay
:
{
date
:
17
,
date
:
17
,
temperature
:
{
value
:
36.75
},
temperature
:
{
value
:
36.75
},
mucus
:
{
value
:
4
}
mucus
:
{
value
:
4
}
,
}
}
},
},
mucusShift
:
{
mucusShift
:
{
...
@@ -68,7 +73,7 @@ describe('sympto', () => {
...
@@ -68,7 +73,7 @@ describe('sympto', () => {
mucusPeak
:
{
mucusPeak
:
{
date
:
17
,
date
:
17
,
mucus
:
{
value
:
4
},
mucus
:
{
value
:
4
},
temperature
:
{
value
:
36.75
}
temperature
:
{
value
:
36.75
}
,
}
}
}
}
})
})
...
...
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