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
2f8054c1
Commit
2f8054c1
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Add mucus shift detection
parent
e4bae38d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/sympto/index.js
+5
-0
5 additions, 0 deletions
lib/sympto/index.js
lib/sympto/mucus.js
+19
-0
19 additions, 0 deletions
lib/sympto/mucus.js
test/sympto/mucus.spec.js
+49
-0
49 additions, 0 deletions
test/sympto/mucus.spec.js
with
73 additions
and
0 deletions
lib/sympto/index.js
+
5
−
0
View file @
2f8054c1
...
...
@@ -4,4 +4,9 @@ import getMucusStatus from './mucus'
export
default
function
(
cycleDays
)
{
const
temperatureStatus
=
getTemperatureStatus
(
cycleDays
)
const
mucusStatus
=
getMucusStatus
(
cycleDays
)
return
{
assumeFertility
:
true
,
temperatureStatus
,
mucusStatus
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/sympto/mucus.js
0 → 100644
+
19
−
0
View file @
2f8054c1
export
default
function
(
cycleDays
)
{
const
mucusDays
=
cycleDays
.
filter
(
day
=>
day
.
mucus
&&
!
day
.
mucus
.
exclude
)
const
bestQuality
=
Math
.
max
(...
mucusDays
.
map
(
day
=>
day
.
mucus
.
value
))
const
mucusPeak
=
mucusDays
.
find
((
day
,
i
)
=>
{
if
(
day
.
mucus
.
value
!==
bestQuality
)
return
false
const
threeFollowingDays
=
cycleDays
.
slice
(
i
+
1
,
i
+
4
)
if
(
threeFollowingDays
.
length
<
3
)
return
false
return
threeFollowingDays
.
every
(
day
=>
day
.
mucus
.
value
<
bestQuality
)
})
if
(
!
mucusPeak
)
return
{
detected
:
false
}
return
{
detected
:
true
,
mucusPeak
}
}
This diff is collapsed.
Click to expand it.
test/sympto/mucus.spec.js
0 → 100644
+
49
−
0
View file @
2f8054c1
import
chai
from
'
chai
'
import
getMucusStatus
from
'
../../lib/sympto/mucus
'
const
expect
=
chai
.
expect
function
turnIntoCycleDayObject
(
value
,
fakeDate
)
{
return
{
mucus
:
{
value
},
date
:
fakeDate
}
}
describe
(
'
sympto
'
,
()
=>
{
describe
(
'
detect mucus shift
'
,
()
=>
{
describe
(
'
regular rule
'
,
()
=>
{
it
(
'
detects mucus shift correctly
'
,
function
()
{
const
values
=
[
0
,
0
,
0
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
2
,
2
,
0
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
0
]
.
map
(
turnIntoCycleDayObject
)
const
status
=
getMucusStatus
(
values
)
expect
(
status
).
to
.
eql
({
detected
:
true
,
mucusPeak
:
{
date
:
10
,
mucus
:
{
value
:
3
}
}
})
})
it
(
'
detects no mucus shift when there are less than 3 days of lower quality
'
,
function
()
{
const
values
=
[
0
,
1
,
1
,
2
,
0
,
0
,
1
,
2
,
3
,
2
,
3
,
3
,
3
,
2
,
2
]
.
map
(
turnIntoCycleDayObject
)
const
status
=
getMucusStatus
(
values
)
expect
(
status
).
to
.
eql
({
detected
:
false
})
})
it
(
'
detects no mucus shift when there are no mucus values
'
,
function
()
{
const
status
=
getMucusStatus
(
Array
(
10
).
fill
({
date
:
1
,
temperature
:
{
value
:
35
}}))
expect
(
status
).
to
.
eql
({
detected
:
false
})
})
it
(
'
detects no mucus shift when the mucus values are all the same
'
,
function
()
{
const
values
=
[
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
]
.
map
(
turnIntoCycleDayObject
)
const
status
=
getMucusStatus
(
values
)
expect
(
status
).
to
.
eql
({
detected
:
false
})
})
})
})
})
\ 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