Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
44ac5b48
Commit
44ac5b48
authored
Oct 12, 2020
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create formatPipelineDuration method
parent
480aed65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
18 deletions
+49
-18
app/assets/javascripts/pipelines/components/pipelines_list/time_ago.vue
...ascripts/pipelines/components/pipelines_list/time_ago.vue
+2
-18
app/assets/javascripts/pipelines/utils.js
app/assets/javascripts/pipelines/utils.js
+19
-0
spec/frontend/pipelines/pipeline_graph/utils_spec.js
spec/frontend/pipelines/pipeline_graph/utils_spec.js
+28
-0
No files found.
app/assets/javascripts/pipelines/components/pipelines_list/time_ago.vue
View file @
44ac5b48
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
{
GlIcon
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
'
~/lib/utils/datetime_utility
'
;
import
'
~/lib/utils/datetime_utility
'
;
import
timeagoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
timeagoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
{
formatPipelineDuration
}
from
'
~/pipelines/utils
'
;
export
default
{
export
default
{
directives
:
{
directives
:
{
...
@@ -27,24 +28,7 @@ export default {
...
@@ -27,24 +28,7 @@ export default {
return
this
.
finishedTime
!==
''
;
return
this
.
finishedTime
!==
''
;
},
},
durationFormatted
()
{
durationFormatted
()
{
const
date
=
new
Date
(
this
.
duration
*
1000
);
return
formatPipelineDuration
(
this
.
duration
);
let
hh
=
date
.
getUTCHours
();
let
mm
=
date
.
getUTCMinutes
();
let
ss
=
date
.
getSeconds
();
// left pad
if
(
hh
<
10
)
{
hh
=
`0
${
hh
}
`
;
}
if
(
mm
<
10
)
{
mm
=
`0
${
mm
}
`
;
}
if
(
ss
<
10
)
{
ss
=
`0
${
ss
}
`
;
}
return
`
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
},
},
},
},
};
};
...
...
app/assets/javascripts/pipelines/utils.js
View file @
44ac5b48
...
@@ -94,3 +94,22 @@ export const generateJobNeedsDict = ({ jobs }) => {
...
@@ -94,3 +94,22 @@ export const generateJobNeedsDict = ({ jobs }) => {
return
{
...
acc
,
[
jobs
[
value
].
id
]:
uniqueValues
};
return
{
...
acc
,
[
jobs
[
value
].
id
]:
uniqueValues
};
},
{});
},
{});
};
};
export
const
formatPipelineDuration
=
duration
=>
{
let
ss
=
duration
%
60
;
let
mm
=
Math
.
floor
(
duration
/
60
)
%
60
;
let
hh
=
Math
.
floor
(
duration
/
60
/
60
);
// left pad with 0s
if
(
hh
<
10
)
{
hh
=
`0
${
hh
}
`
;
}
if
(
mm
<
10
)
{
mm
=
`0
${
mm
}
`
;
}
if
(
ss
<
10
)
{
ss
=
`0
${
ss
}
`
;
}
return
`
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
};
spec/frontend/pipelines/pipeline_graph/utils_spec.js
View file @
44ac5b48
...
@@ -2,6 +2,7 @@ import {
...
@@ -2,6 +2,7 @@ import {
preparePipelineGraphData
,
preparePipelineGraphData
,
createUniqueJobId
,
createUniqueJobId
,
generateJobNeedsDict
,
generateJobNeedsDict
,
formatPipelineDuration
,
}
from
'
~/pipelines/utils
'
;
}
from
'
~/pipelines/utils
'
;
describe
(
'
utils functions
'
,
()
=>
{
describe
(
'
utils functions
'
,
()
=>
{
...
@@ -209,3 +210,30 @@ describe('utils functions', () => {
...
@@ -209,3 +210,30 @@ describe('utils functions', () => {
});
});
});
});
});
});
describe
(
'
formatPipelineDuration
'
,
()
=>
{
it
(
'
formats durations >= 1 day correctly
'
,
()
=>
{
const
oneDay
=
60
*
60
*
24
;
expect
(
formatPipelineDuration
(
oneDay
)).
toBe
(
'
24:00:00
'
);
expect
(
formatPipelineDuration
(
oneDay
*
2
)).
toBe
(
'
48:00:00
'
);
expect
(
formatPipelineDuration
(
oneDay
+
60
*
5
+
34
)).
toBe
(
'
24:05:34
'
);
expect
(
formatPipelineDuration
(
oneDay
*
10
)).
toBe
(
'
240:00:00
'
);
expect
(
formatPipelineDuration
(
oneDay
*
100
)).
toBe
(
'
2400:00:00
'
);
});
describe
(
'
durations < 1 day
'
,
()
=>
{
it
.
each
`
input | output
${
0
}
|
${
'
00:00:00
'
}
${
10
}
|
${
'
00:00:10
'
}
${
60
}
|
${
'
00:01:00
'
}
${
61
}
|
${
'
00:01:01
'
}
${
3600
}
|
${
'
01:00:00
'
}
${
4660
}
|
${
'
01:17:40
'
}
${
86399
}
|
${
'
23:59:59
'
}
`
(
'
returns $output for $input
'
,
({
input
,
output
})
=>
{
expect
(
formatPipelineDuration
(
input
)).
toBe
(
output
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment