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
ab1ed969
Commit
ab1ed969
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Change getCycleDayNumber signature and some PR improvements
parent
f98a6019
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
bleeding.js
+2
-3
2 additions, 3 deletions
bleeding.js
day-view.js
+4
-4
4 additions, 4 deletions
day-view.js
get-cycle-day-number.js
+6
-6
6 additions, 6 deletions
get-cycle-day-number.js
home.js
+2
-3
2 additions, 3 deletions
home.js
test/get-cycle-day.spec.js
+7
-7
7 additions, 7 deletions
test/get-cycle-day.spec.js
with
21 additions
and
23 deletions
bleeding.js
+
2
−
3
View file @
ab1ed969
...
...
@@ -11,9 +11,8 @@ import { saveBleeding } from './db'
import
{
formatDateForViewHeader
}
from
'
./format
'
import
{
bleeding
as
labels
}
from
'
./labels
'
import
cycleDayModule
from
'
./get-cycle-day-number
'
import
{
bleedingDaysSortedByDate
}
from
'
./db
'
const
getCycleDay
=
cycleDayModule
(
bleedingDaysSortedByDate
)
const
getCycleDay
Number
=
cycleDayModule
()
export
default
class
Bleeding
extends
Component
{
constructor
(
props
)
{
...
...
@@ -43,7 +42,7 @@ export default class Bleeding extends Component {
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
welcome
}
>
{
formatDateForViewHeader
(
day
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
(
day
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
Number
(
day
.
date
)}
<
/Text
>
<
Text
>
Bleeding
<
/Text
>
<
RadioForm
radio_props
=
{
bleedingRadioProps
}
...
...
This diff is collapsed.
Click to expand it.
day-view.js
+
4
−
4
View file @
ab1ed969
...
...
@@ -10,14 +10,14 @@ import { bleeding as labels} from './labels'
import
cycleDayModule
from
'
./get-cycle-day-number
'
import
{
bleedingDaysSortedByDate
}
from
'
./db
'
const
getCycleDay
=
cycleDayModule
(
bleedingDaysSortedByDate
)
const
getCycleDay
Number
=
cycleDayModule
()
export
default
class
DayView
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
cycleDay
=
props
.
navigation
.
state
.
params
.
cycleDay
this
.
state
=
{
cycleDayNumber
:
getCycleDay
(
this
.
cycleDay
.
date
),
cycleDayNumber
:
getCycleDay
Number
(
this
.
cycleDay
.
date
),
}
bleedingDaysSortedByDate
.
addListener
(
setStateWithCurrentCycleDayNumber
.
bind
(
this
))
}
...
...
@@ -40,7 +40,7 @@ export default class DayView extends Component {
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
welcome
}
>
{
formatDateForViewHeader
(
day
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
(
day
.
date
)}
<
/Text
>
<
Text
>
Cycle
day
{
getCycleDay
Number
(
day
.
date
)}
<
/Text
>
<
Text
style
=
{
styles
.
welcome
}
>
{
bleedingLabel
}
<
/Text
>
<
Button
onPress
=
{()
=>
navigate
(
'
bleeding
'
,
{
cycleDay
:
day
})}
...
...
@@ -53,6 +53,6 @@ export default class DayView extends Component {
function
setStateWithCurrentCycleDayNumber
()
{
this
.
setState
({
cycleDayNumber
:
getCycleDay
(
this
.
cycleDay
.
date
)
cycleDayNumber
:
getCycleDay
Number
(
this
.
cycleDay
.
date
)
})
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
get-cycle-day-number.js
+
6
−
6
View file @
ab1ed969
import
*
as
joda
from
'
js-joda
'
import
{
bleedingDaysSortedByDate
as
bleedingDaysSortedByDateView
}
from
'
./db
'
const
LocalDate
=
joda
.
LocalDate
export
default
function
config
(
bleedingDaysSortedByDateView
,
opts
)
{
opts
=
opts
||
{
maxBreakInBleeding
:
1
}
export
default
function
config
(
opts
=
{})
{
const
bleedingDaysSortedByDate
=
opts
.
bleedingDaysSortedByDate
||
bleedingDaysSortedByDateView
const
maxBreakInBleeding
=
opts
.
maxBreakInBleeding
||
1
return
function
getCycleDayNumber
(
targetDateString
)
{
const
targetDate
=
LocalDate
.
parse
(
targetDateString
)
const
withWrappedDates
=
bleedingDaysSortedByDate
View
const
withWrappedDates
=
bleedingDaysSortedByDate
.
filter
(
day
=>
!
day
.
bleeding
.
exclude
)
.
map
(
day
=>
{
day
.
wrappedDate
=
LocalDate
.
parse
(
day
.
date
)
...
...
@@ -21,7 +21,7 @@ export default function config(bleedingDaysSortedByDateView, opts) {
const
previousBleedingDays
=
withWrappedDates
.
slice
(
firstBleedingDayBeforeTargetDayIndex
)
const
lastPeriodStart
=
previousBleedingDays
.
find
((
day
,
i
)
=>
{
return
thereIsNoPreviousBleedingDayWithinTheThreshold
(
day
,
previousBleedingDays
.
slice
(
i
+
1
),
opts
.
maxBreakInBleeding
)
return
thereIsNoPreviousBleedingDayWithinTheThreshold
(
day
,
previousBleedingDays
.
slice
(
i
+
1
),
maxBreakInBleeding
)
})
const
diffInDays
=
lastPeriodStart
.
wrappedDate
.
until
(
targetDate
,
joda
.
ChronoUnit
.
DAYS
)
...
...
This diff is collapsed.
Click to expand it.
home.js
+
2
−
3
View file @
ab1ed969
...
...
@@ -9,13 +9,12 @@ import cycleDayModule from './get-cycle-day-number'
import
{
bleedingDaysSortedByDate
,
deleteAll
}
from
'
./db
'
import
{
LocalDate
}
from
'
js-joda
'
const
getCycleDayNumber
=
cycleDayModule
(
bleedingDaysSortedByDate
)
const
getCycleDayNumber
=
cycleDayModule
()
export
default
class
Home
extends
Component
{
constructor
(
props
)
{
super
(
props
)
const
now
=
new
Date
()
this
.
todayDateString
=
LocalDate
.
of
(
now
.
getFullYear
(),
now
.
getMonth
()
+
1
,
now
.
getDate
()).
toString
()
this
.
todayDateString
=
LocalDate
.
now
().
toString
()
const
cycleDayNumber
=
getCycleDayNumber
(
this
.
todayDateString
)
this
.
state
=
{
...
...
This diff is collapsed.
Click to expand it.
test/get-cycle-day.spec.js
+
7
−
7
View file @
ab1ed969
...
...
@@ -24,7 +24,7 @@ describe('getCycleDay', () => {
value
:
2
}
}]
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
}
)
const
targetDate
=
'
2018-05-17
'
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
eql
(
9
)
...
...
@@ -50,7 +50,7 @@ describe('getCycleDay', () => {
}
}]
const
targetDate
=
'
2018-05-17
'
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
}
)
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
eql
(
15
)
})
...
...
@@ -74,7 +74,7 @@ describe('getCycleDay', () => {
}]
const
targetDate
=
'
2018-04-27
'
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
}
)
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
eql
(
18
)
})
...
...
@@ -84,14 +84,14 @@ describe('getCycleDay returns null', () => {
it
(
'
if there are no bleeding days
'
,
function
()
{
const
bleedingDays
=
[]
const
targetDate
=
'
2018-05-17
'
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
}
)
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
be
.
null
()
})
})
describe
(
'
getCycleDay with cycle thresholds
'
,
()
=>
{
const
opts
=
{
maxBreakInBleeding
:
3
}
const
maxBreakInBleeding
=
3
it
(
'
disregards bleeding breaks shorter than max allowed bleeding break in a bleeding period
'
,
()
=>
{
const
bleedingDays
=
[{
...
...
@@ -107,7 +107,7 @@ describe('getCycleDay with cycle thresholds', () => {
}]
const
targetDate
=
'
2018-05-17
'
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
,
opts
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
,
maxBreakInBleeding
}
)
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
eql
(
8
)
})
...
...
@@ -125,7 +125,7 @@ describe('getCycleDay with cycle thresholds', () => {
}
}]
const
targetDate
=
'
2018-05-17
'
const
getCycleDayNumber
=
getCycleDayNumberModule
(
bleedingDays
,
opts
)
const
getCycleDayNumber
=
getCycleDayNumberModule
(
{
bleedingDays
SortedByDate
:
bleedingDays
,
maxBreakInBleeding
}
)
const
result
=
getCycleDayNumber
(
targetDate
)
expect
(
result
).
to
.
eql
(
4
)
})
...
...
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