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
81b7b46b
Commit
81b7b46b
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Use explicit dates with gaps and fix bugs that this uncovers
parent
0de00933
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/pre-ovulatory.js
+6
-2
6 additions, 2 deletions
lib/sympto/pre-ovulatory.js
test/sympto/fixtures.js
+53
-68
53 additions, 68 deletions
test/sympto/fixtures.js
test/sympto/index.spec.js
+7
-7
7 additions, 7 deletions
test/sympto/index.spec.js
with
66 additions
and
77 deletions
lib/sympto/pre-ovulatory.js
+
6
−
2
View file @
81b7b46b
import
{
LocalDate
}
from
"
js-joda
"
export
default
function
(
cycle
)
{
const
fiveDayRuleDays
=
cycle
.
slice
(
0
,
5
)
const
startDate
=
LocalDate
.
parse
(
cycle
[
0
].
date
)
const
fiveDayEndDate
=
startDate
.
plusDays
(
4
).
toString
()
const
fiveDayRuleDays
=
cycle
.
slice
(
0
,
5
).
filter
(
d
=>
d
.
date
<=
fiveDayEndDate
)
const
preOvulatoryDays
=
getDaysUntilFertileMucus
(
fiveDayRuleDays
)
return
{
cycleDays
:
preOvulatoryDays
,
...
...
@@ -7,7 +11,7 @@ export default function(cycle) {
date
:
preOvulatoryDays
[
0
].
date
},
end
:
{
date
:
preOvulatoryDays
[
preOvulatoryDays
.
length
-
1
].
d
ate
,
date
:
fiveDayEndD
ate
}
}
}
...
...
This diff is collapsed.
Click to expand it.
test/sympto/fixtures.js
+
53
−
68
View file @
81b7b46b
function
convertToSymptoFormat
(
val
,
i
)
{
++
i
const
dayString
=
i
<
10
?
`0
${
i
}
`
:
i
const
sympto
=
{
date
:
`2018-06-
${
dayString
}
`
}
function
convertToSymptoFormat
(
val
)
{
const
sympto
=
{
date
:
val
.
date
}
if
(
val
.
temperature
)
sympto
.
temperature
=
{
value
:
val
.
temperature
}
if
(
val
.
mucus
)
sympto
.
mucus
=
{
value
:
val
.
mucus
}
if
(
val
.
bleeding
)
sympto
.
bleeding
=
{
value
:
val
.
bleeding
}
...
...
@@ -10,85 +8,72 @@ function convertToSymptoFormat(val, i) {
}
const
cycleWithTempShift
=
[
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.8
,
36.8
,
36.8
]
.
map
(
num
=>
({
temperature
:
num
}))
.
map
(
num
=>
({
date
:
'
2018-06-01
'
,
temperature
:
num
}))
.
map
(
convertToSymptoFormat
)
const
cycleWithoutTempShift
=
[
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.8
,
36.8
]
.
map
(
num
=>
({
temperature
:
num
}))
.
map
(
num
=>
({
date
:
'
2018-06-01
'
,
temperature
:
num
}))
.
map
(
convertToSymptoFormat
)
const
cycleWithTempAndMucusShift
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.4
,
mucus
:
2
},
{
temperature
:
36.5
,
mucus
:
3
},
{
temperature
:
36.55
,
mucus
:
3
},
{
temperature
:
36.45
,
mucus
:
3
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.55
,
mucus
:
4
},
{
temperature
:
36.7
,
mucus
:
3
},
{
temperature
:
36.65
,
mucus
:
3
},
{
temperature
:
36.75
,
mucus
:
4
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
2
},
{
temperature
:
36.8
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
}
{
date
:
'
2018-06-01
'
,
temperature
:
36.6
,
bleeding
:
2
},
{
date
:
'
2018-06-02
'
,
temperature
:
36.65
},
{
date
:
'
2018-06-04
'
,
temperature
:
36.6
},
{
date
:
'
2018-06-05
'
,
temperature
:
36.55
},
{
date
:
'
2018-06-06
'
,
temperature
:
36.7
,
mucus
:
0
},
{
date
:
'
2018-06-09
'
,
temperature
:
36.5
,
mucus
:
4
},
{
date
:
'
2018-06-10
'
,
temperature
:
36.4
,
mucus
:
2
},
{
date
:
'
2018-06-13
'
,
temperature
:
36.45
,
mucus
:
3
},
{
date
:
'
2018-06-14
'
,
temperature
:
36.5
,
mucus
:
4
},
{
date
:
'
2018-06-15
'
,
temperature
:
36.55
,
mucus
:
4
},
{
date
:
'
2018-06-16
'
,
temperature
:
36.7
,
mucus
:
3
},
{
date
:
'
2018-06-17
'
,
temperature
:
36.65
,
mucus
:
3
},
{
date
:
'
2018-06-18
'
,
temperature
:
36.75
,
mucus
:
4
},
{
date
:
'
2018-06-19
'
,
temperature
:
36.8
,
mucus
:
1
},
{
date
:
'
2018-06-20
'
,
temperature
:
36.85
,
mucus
:
2
},
{
date
:
'
2018-06-21
'
,
temperature
:
36.8
,
mucus
:
2
},
{
date
:
'
2018-06-22
'
,
temperature
:
36.9
,
mucus
:
2
},
{
date
:
'
2018-06-25
'
,
temperature
:
36.9
,
mucus
:
1
},
{
date
:
'
2018-06-26
'
,
temperature
:
36.8
,
mucus
:
1
},
{
date
:
'
2018-06-27
'
,
temperature
:
36.9
,
mucus
:
1
}
].
map
(
convertToSymptoFormat
)
const
cycleWithTempAndNoMucusShift
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.4
,
mucus
:
2
},
{
temperature
:
36.5
,
mucus
:
3
},
{
temperature
:
36.55
,
mucus
:
3
},
{
temperature
:
36.45
,
mucus
:
3
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.55
,
mucus
:
4
},
{
temperature
:
36.7
,
mucus
:
3
},
{
temperature
:
36.65
,
mucus
:
3
},
{
temperature
:
36.75
,
mucus
:
4
},
{
temperature
:
36.8
,
mucus
:
4
},
{
temperature
:
36.85
,
mucus
:
4
},
{
temperature
:
36.8
,
mucus
:
4
},
{
temperature
:
36.9
,
mucus
:
4
}
{
date
:
'
2018-06-01
'
,
temperature
:
36.6
,
bleeding
:
2
},
{
date
:
'
2018-06-02
'
,
temperature
:
36.65
},
{
date
:
'
2018-06-05
'
,
temperature
:
36.55
},
{
date
:
'
2018-06-06
'
,
temperature
:
36.7
,
mucus
:
0
},
{
date
:
'
2018-06-08
'
,
temperature
:
36.45
,
mucus
:
1
},
{
date
:
'
2018-06-09
'
,
temperature
:
36.5
,
mucus
:
4
},
{
date
:
'
2018-06-10
'
,
temperature
:
36.4
,
mucus
:
2
},
{
date
:
'
2018-06-11
'
,
temperature
:
36.5
,
mucus
:
3
},
{
date
:
'
2018-06-13
'
,
temperature
:
36.45
,
mucus
:
3
},
{
date
:
'
2018-06-14
'
,
temperature
:
36.5
,
mucus
:
4
},
{
date
:
'
2018-06-15
'
,
temperature
:
36.55
,
mucus
:
4
},
{
date
:
'
2018-06-16
'
,
temperature
:
36.7
,
mucus
:
3
},
{
date
:
'
2018-06-17
'
,
temperature
:
36.65
,
mucus
:
3
},
{
date
:
'
2018-06-18
'
,
temperature
:
36.75
,
mucus
:
4
},
{
date
:
'
2018-06-19
'
,
temperature
:
36.8
,
mucus
:
4
},
{
date
:
'
2018-06-20
'
,
temperature
:
36.85
,
mucus
:
4
},
{
date
:
'
2018-06-23
'
,
temperature
:
36.9
,
mucus
:
3
},
{
date
:
'
2018-06-24
'
,
temperature
:
36.85
,
mucus
:
4
},
{
date
:
'
2018-06-26
'
,
temperature
:
36.8
,
mucus
:
4
},
{
date
:
'
2018-06-27
'
,
temperature
:
36.9
,
mucus
:
4
}
].
map
(
convertToSymptoFormat
)
const
cycleWithoutAnyShifts
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
}
{
date
:
'
2018-06-01
'
,
temperature
:
36.6
,
bleeding
:
2
},
{
date
:
'
2018-06-02
'
,
temperature
:
36.65
},
{
date
:
'
2018-06-04
'
,
temperature
:
36.6
},
{
date
:
'
2018-06-05
'
,
temperature
:
36.55
},
{
date
:
'
2018-06-06
'
,
temperature
:
36.7
,
mucus
:
0
},
{
date
:
'
2018-06-07
'
,
temperature
:
36.75
,
mucus
:
0
},
{
date
:
'
2018-06-08
'
,
temperature
:
36.45
,
mucus
:
1
}
].
map
(
convertToSymptoFormat
)
const
fiveDayCycle
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
}
{
date
:
'
2018-06-01
'
,
bleeding
:
2
},
{
date
:
'
2018-06-03
'
,
bleeding
:
3
},
].
map
(
convertToSymptoFormat
)
export
{
...
...
This diff is collapsed.
Click to expand it.
test/sympto/index.spec.js
+
7
−
7
View file @
81b7b46b
...
...
@@ -39,14 +39,14 @@ describe('sympto', () => {
expect
(
status
.
phases
.
periOvulatory
).
to
.
eql
({
start
:
{
date
:
'
2018-06-01
'
},
end
:
{
date
:
'
2018-06-21
'
,
time
:
'
18:00
'
},
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
0
,
21
)
cycleDays
:
cycleWithTempAndMucusShift
.
filter
(({
date
})
=>
date
<=
'
2018-06-
21
'
)
})
expect
(
status
.
phases
.
postOvulatory
).
to
.
eql
({
start
:
{
date
:
'
2018-06-21
'
,
time
:
'
18:00
'
},
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
20
)
cycleDays
:
cycleWithTempAndMucusShift
.
filter
(({
date
})
=>
date
>=
'
2018-06-21
'
)
})
})
})
...
...
@@ -79,12 +79,12 @@ describe('sympto', () => {
expect
(
Object
.
keys
(
status
.
phases
).
length
).
to
.
eql
(
2
)
expect
(
status
.
assumeFertility
).
to
.
be
.
true
()
expect
(
status
.
phases
.
preOvulatory
).
to
.
eql
({
cycleDays
:
cycleWithTempAndNoMucusShift
.
slice
(
0
,
5
),
cycleDays
:
cycleWithTempAndNoMucusShift
.
filter
(({
date
})
=>
date
<=
'
2018-06-05
'
),
start
:
{
date
:
'
2018-06-01
'
},
end
:
{
date
:
'
2018-06-05
'
}
})
expect
(
status
.
phases
.
periOvulatory
).
to
.
eql
({
cycleDays
:
cycleWithTempAndNoMucusShift
.
slice
(
5
),
cycleDays
:
cycleWithTempAndNoMucusShift
.
filter
(({
date
})
=>
date
>
'
2018-06-05
'
),
start
:
{
date
:
'
2018-06-06
'
}
})
})
...
...
@@ -100,17 +100,17 @@ describe('sympto', () => {
expect
(
Object
.
keys
(
status
.
phases
).
length
).
to
.
eql
(
3
)
expect
(
status
.
assumeFertility
).
to
.
be
.
false
()
expect
(
status
.
phases
.
preOvulatory
).
to
.
eql
({
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
0
,
5
),
cycleDays
:
cycleWithTempAndMucusShift
.
filter
(({
date
})
=>
date
<=
'
2018-06-05
'
),
start
:
{
date
:
'
2018-06-01
'
},
end
:
{
date
:
'
2018-06-05
'
}
})
expect
(
status
.
phases
.
periOvulatory
).
to
.
eql
({
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
5
,
21
),
cycleDays
:
cycleWithTempAndMucusShift
.
filter
(({
date
})
=>
date
>
'
2018-06-05
'
&&
date
<=
'
2018-06-21
'
),
start
:
{
date
:
'
2018-06-06
'
},
end
:
{
date
:
'
2018-06-21
'
,
time
:
'
18:00
'
}
})
expect
(
status
.
phases
.
postOvulatory
).
to
.
eql
({
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
20
),
cycleDays
:
cycleWithTempAndMucusShift
.
filter
(({
date
})
=>
date
>=
'
2018-06-21
'
),
start
:
{
date
:
'
2018-06-21
'
,
time
:
'
18:00
'
}
})
})
...
...
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