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
6135c922
Commit
6135c922
authored
6 years ago
by
tina
Browse files
Options
Downloads
Patches
Plain Diff
possible to get all cycle lengths, which get evaluated in stats
parent
897e99e6
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
components/stats.js
+22
-12
22 additions, 12 deletions
components/stats.js
lib/cycle.js
+19
-2
19 additions, 2 deletions
lib/cycle.js
with
41 additions
and
14 deletions
components/stats.js
+
22
−
12
View file @
6135c922
...
...
@@ -4,7 +4,7 @@ import {
Text
,
ScrollView
}
from
'
react-native
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
LocalDate
,
ChronoUnit
}
from
'
js-joda
'
import
styles
from
'
../styles/index
'
import
cycleModule
from
'
../lib/cycle
'
import
getPeriodInfo
from
'
../lib/period-length
'
...
...
@@ -12,21 +12,20 @@ import getPeriodInfo from '../lib/period-length'
export
default
class
Stats
extends
Component
{
constructor
(
props
)
{
super
(
props
)
const
lastMensStart
=
cycleModule
().
getLastMensesStart
(
LocalDate
.
now
().
toString
()
)
const
completedCycles
=
cycleModule
().
getCyclesBefore
(
lastMensStart
)
this
.
numberOfCycles
=
completedCycles
.
length
// TODO get first days, compare with joda
const
periodLengths
=
completedCycles
.
map
(
cycle
=>
{
return
cycle
.
length
})
// until this point
this
.
periodInfo
=
getPeriodInfo
(
periodLengths
)
const
allMensesStarts
=
cycleModule
().
getAllMensesStarts
()
this
.
test
=
allMensesStarts
const
cycleLengths
=
getCycleLength
(
allMensesStarts
)
this
.
bla
=
cycleLengths
this
.
numberOfCycles
=
cycleLengths
.
length
this
.
periodInfo
=
getPeriodInfo
(
cycleLengths
)
}
render
()
{
console
.
log
(
'
...............
'
)
console
.
log
(
this
.
test
)
console
.
log
(
this
.
bla
)
return
(
<
ScrollView
>
<
Text
style
=
{
styles
.
welcome
}
>
based
on
{
this
.
numberOfCycles
}
periods
:
<
/Text
>
...
...
@@ -38,4 +37,15 @@ export default class Stats extends Component {
<
/ScrollView
>
)
}
}
function
getCycleLength
(
cycleStartDates
)
{
const
cycleStartDatesReverse
=
cycleStartDates
.
reverse
()
const
periodLengths
=
[]
for
(
let
i
=
0
;
i
<
cycleStartDates
.
length
-
1
;
i
++
)
{
const
periodStart
=
LocalDate
.
parse
(
cycleStartDatesReverse
[
i
])
const
periodEnd
=
LocalDate
.
parse
(
cycleStartDatesReverse
[
i
+
1
])
periodLengths
.
unshift
(
periodStart
.
until
(
periodEnd
,
ChronoUnit
.
DAYS
))
}
return
periodLengths
.
reverse
()
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/cycle.js
+
19
−
2
View file @
6135c922
...
...
@@ -130,11 +130,28 @@ export default function config(opts) {
}
}
function
getAllMensesStarts
(
day
,
collectedDates
)
{
day
=
day
||
LocalDate
.
now
().
toString
()
collectedDates
=
collectedDates
||
[]
if
(
!
day
)
{
return
null
}
else
{
const
lastStart
=
getLastMensesStart
(
day
)
if
(
!
lastStart
)
{
return
collectedDates
}
else
{
const
newDay
=
LocalDate
.
parse
(
lastStart
.
date
).
minusDays
(
1
).
toString
()
collectedDates
.
push
(
lastStart
.
date
)
return
getAllMensesStarts
(
newDay
,
collectedDates
)
}
}
}
return
{
getCycleDayNumber
,
getCycleForDay
,
getPreviousCycle
,
get
CyclesBefore
,
get
Last
MensesStart
get
LastMensesStart
,
get
All
MensesStart
s
}
}
\ 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