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
77ad491d
Commit
77ad491d
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Return evaluation completed day from mucus eval
parent
9102bce7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/sympto/mucus.js
+20
-14
20 additions, 14 deletions
lib/sympto/mucus.js
test/sympto/mucus.spec.js
+5
-1
5 additions, 1 deletion
test/sympto/mucus.spec.js
with
25 additions
and
15 deletions
lib/sympto/mucus.js
+
20
−
14
View file @
77ad491d
...
...
@@ -2,31 +2,37 @@ export default function (cycleDays, tempEvalEndIndex) {
const
mucusDays
=
cycleDays
.
filter
(
day
=>
day
.
mucus
&&
!
day
.
mucus
.
exclude
)
const
bestQuality
=
Math
.
max
(...
mucusDays
.
map
(
day
=>
day
.
mucus
.
value
))
const
mucusPeak
=
cycleDays
.
find
((
day
,
i
)
=>
{
if
(
!
mucusDays
.
includes
(
day
)
||
day
.
mucus
.
value
!==
bestQuality
)
return
false
for
(
let
i
=
0
;
i
<
mucusDays
.
length
;
i
++
)
{
const
day
=
mucusDays
[
i
]
if
(
day
.
mucus
.
value
!==
bestQuality
)
continue
// sensiplan says the three following days must be of lower quality
// AND no best quality day may occur until temperature evaluation has
// been completed
const
mucusDaysIndex
=
mucusDays
.
indexOf
(
day
)
const
threeFollowingDays
=
mucusDays
.
slice
(
mucusDaysIndex
+
1
,
mucusDaysIndex
+
4
)
if
(
threeFollowingDays
.
length
<
3
)
return
false
const
threeFollowingDays
=
mucusDays
.
slice
(
i
+
1
,
i
+
4
)
if
(
threeFollowingDays
.
length
<
3
)
continue
const
bestQualityOccurringIn3FollowingDays
=
threeFollowingDays
.
some
(
day
=>
day
.
mucus
.
value
>=
bestQuality
)
if
(
bestQualityOccurringIn3FollowingDays
)
return
fals
e
if
(
bestQualityOccurringIn3FollowingDays
)
continu
e
// FIXME mucus peak can be same day as first higher measurement
const
cycleDayIndex
=
cycleDays
.
indexOf
(
day
)
const
relevantDays
=
cycleDays
.
slice
(
i
+
1
,
tempEvalEndIndex
+
1
)
.
slice
(
cycleDayIndex
+
1
,
tempEvalEndIndex
+
1
)
.
filter
(
day
=>
day
.
mucus
&&
!
day
.
mucus
.
exclude
)
return
relevantDays
.
every
(
day
=>
day
.
mucus
.
value
<
bestQuality
)
})
const
evaluationCompleteDay
=
relevantDays
.
length
>
3
?
relevantDays
[
relevantDays
.
length
-
1
]
:
threeFollowingDays
[
threeFollowingDays
.
length
-
1
]
if
(
!
mucusPeak
)
return
{
detected
:
false
}
return
{
detected
:
true
,
mucusPeak
if
(
relevantDays
.
every
(
day
=>
day
.
mucus
.
value
<
bestQuality
))
{
return
{
detected
:
true
,
mucusPeak
:
day
,
evaluationCompleteDay
}
}
}
return
{
detected
:
false
}
}
This diff is collapsed.
Click to expand it.
test/sympto/mucus.spec.js
+
5
−
1
View file @
77ad491d
...
...
@@ -16,12 +16,16 @@ describe('sympto', () => {
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
,
30
)
const
status
=
getMucusStatus
(
values
,
12
)
expect
(
status
).
to
.
eql
({
detected
:
true
,
mucusPeak
:
{
date
:
10
,
mucus
:
{
value
:
3
}
},
evaluationCompleteDay
:
{
date
:
13
,
mucus
:
{
value
:
0
}
}
})
})
...
...
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