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
2f9b08fd
Commit
2f9b08fd
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Shorten line lengths in cycle
parent
e1fa656b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/cycle.js
+23
-14
23 additions, 14 deletions
lib/cycle.js
with
23 additions
and
14 deletions
lib/cycle.js
+
23
−
14
View file @
2f9b08fd
import
*
as
joda
from
'
js-joda
'
import
*
as
joda
from
'
js-joda
'
const
LocalDate
=
joda
.
LocalDate
const
LocalDate
=
joda
.
LocalDate
const
DAYS
=
joda
.
ChronoUnit
.
DAYS
export
default
function
config
(
opts
)
{
export
default
function
config
(
opts
)
{
let
bleedingDaysSortedByDate
let
bleedingDaysSortedByDate
...
@@ -28,28 +28,31 @@ export default function config(opts) {
...
@@ -28,28 +28,31 @@ export default function config(opts) {
return
day
return
day
})
})
const
firstBleeding
Day
BeforeTargetDayIndex
=
withWrappedDates
.
findIndex
(
day
=>
{
const
firstBleedingBeforeTargetDayIndex
=
withWrappedDates
.
findIndex
(
day
=>
{
return
(
return
(
day
.
wrappedDate
.
isEqual
(
targetDate
)
||
day
.
wrappedDate
.
isEqual
(
targetDate
)
||
day
.
wrappedDate
.
isBefore
(
targetDate
)
day
.
wrappedDate
.
isBefore
(
targetDate
)
)
)
})
})
if
(
firstBleeding
Day
BeforeTargetDayIndex
<
0
)
{
if
(
firstBleedingBeforeTargetDayIndex
<
0
)
{
withWrappedDates
.
forEach
(
day
=>
delete
day
.
wrappedDate
)
withWrappedDates
.
forEach
(
day
=>
delete
day
.
wrappedDate
)
return
null
return
null
}
}
const
prev
ious
BleedingDays
=
withWrappedDates
.
slice
(
firstBleeding
Day
BeforeTargetDayIndex
)
const
prevBleedingDays
=
withWrappedDates
.
slice
(
firstBleedingBeforeTargetDayIndex
)
const
lastMensesStart
=
prev
ious
BleedingDays
.
find
((
day
,
i
)
=>
{
const
lastMensesStart
=
prevBleedingDays
.
find
((
day
,
i
)
=>
{
return
thereIsNoPrevious
BleedingDayWithinTh
eTh
reshold
(
day
,
prev
ious
BleedingDays
.
slice
(
i
+
1
))
return
no
BleedingDayWithinThreshold
(
day
,
prevBleedingDays
.
slice
(
i
+
1
))
})
})
function
thereIsNoPrevious
BleedingDayWithinTh
eTh
reshold
(
bleedingD
ay
,
previousBleedingDays
)
{
function
no
BleedingDayWithinThreshold
(
d
ay
,
previousBleedingDays
)
{
const
periodThreshold
=
bleedingD
ay
.
wrappedDate
.
minusDays
(
maxBreakInBleeding
+
1
)
const
periodThreshold
=
d
ay
.
wrappedDate
.
minusDays
(
maxBreakInBleeding
+
1
)
return
!
previousBleedingDays
.
some
(({
wrappedDate
})
=>
{
return
!
previousBleedingDays
.
some
(({
wrappedDate
})
=>
{
return
wrappedDate
.
equals
(
periodThreshold
)
||
wrappedDate
.
isAfter
(
periodThreshold
)
return
(
wrappedDate
.
equals
(
periodThreshold
)
||
wrappedDate
.
isAfter
(
periodThreshold
)
)
})
})
}
}
...
@@ -66,9 +69,11 @@ export default function config(opts) {
...
@@ -66,9 +69,11 @@ export default function config(opts) {
return
day
return
day
})
})
const
firstBleedingDayAfterTargetDay
=
withWrappedDates
.
reverse
().
find
(
day
=>
{
const
firstBleedingDayAfterTargetDay
=
withWrappedDates
return
day
.
wrappedDate
.
isAfter
(
targetDate
)
.
reverse
()
})
.
find
(
day
=>
{
return
day
.
wrappedDate
.
isAfter
(
targetDate
)
})
withWrappedDates
.
forEach
(
day
=>
delete
day
.
wrappedDate
)
withWrappedDates
.
forEach
(
day
=>
delete
day
.
wrappedDate
)
...
@@ -80,7 +85,7 @@ export default function config(opts) {
...
@@ -80,7 +85,7 @@ export default function config(opts) {
if
(
!
lastMensesStart
)
return
null
if
(
!
lastMensesStart
)
return
null
const
targetDate
=
LocalDate
.
parse
(
targetDateString
)
const
targetDate
=
LocalDate
.
parse
(
targetDateString
)
const
lastMensesLocalDate
=
LocalDate
.
parse
(
lastMensesStart
.
date
)
const
lastMensesLocalDate
=
LocalDate
.
parse
(
lastMensesStart
.
date
)
const
diffInDays
=
lastMensesLocalDate
.
until
(
targetDate
,
joda
.
ChronoUnit
.
DAYS
)
const
diffInDays
=
lastMensesLocalDate
.
until
(
targetDate
,
DAYS
)
// cycle starts at day 1
// cycle starts at day 1
return
diffInDays
+
1
return
diffInDays
+
1
...
@@ -100,7 +105,11 @@ export default function config(opts) {
...
@@ -100,7 +105,11 @@ export default function config(opts) {
function
getPreviousCycle
(
dateString
)
{
function
getPreviousCycle
(
dateString
)
{
const
startOfCycle
=
getLastMensesStart
(
dateString
)
const
startOfCycle
=
getLastMensesStart
(
dateString
)
if
(
!
startOfCycle
)
return
null
if
(
!
startOfCycle
)
return
null
const
dateBeforeStartOfCycle
=
LocalDate
.
parse
(
startOfCycle
.
date
).
minusDays
(
1
).
toString
()
const
dateBeforeStartOfCycle
=
LocalDate
.
parse
(
startOfCycle
.
date
)
.
minusDays
(
1
)
.
toString
()
return
getCycleForDay
(
dateBeforeStartOfCycle
)
return
getCycleForDay
(
dateBeforeStartOfCycle
)
}
}
...
...
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