Commit 7299065d authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'add-total-duration-to-cicd-analytics-page' into 'master'

Add Total Duration to CI/CD Analytics Page

See merge request gitlab-org/gitlab!44863
parents 1698c5a9 07a56863
<script> <script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import '~/lib/utils/datetime_utility';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import { formatTime } from '~/lib/utils/datetime_utility';
export default { export default {
directives: { directives: {
...@@ -27,24 +27,7 @@ export default { ...@@ -27,24 +27,7 @@ export default {
return this.finishedTime !== ''; return this.finishedTime !== '';
}, },
durationFormatted() { durationFormatted() {
const date = new Date(this.duration * 1000); return formatTime(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}`;
}, },
}, },
}; };
......
<script> <script>
import { formatTime } from '~/lib/utils/datetime_utility';
import { s__, n__ } from '~/locale';
export default { export default {
props: { props: {
counts: { counts: {
...@@ -6,25 +9,44 @@ export default { ...@@ -6,25 +9,44 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
totalDuration() {
return formatTime(this.counts.totalDuration);
},
statistics() {
return [
{
title: s__('PipelineCharts|Total:'),
value: n__('1 pipeline', '%d pipelines', this.counts.total),
},
{
title: s__('PipelineCharts|Successful:'),
value: n__('1 pipeline', '%d pipelines', this.counts.success),
},
{
title: s__('PipelineCharts|Failed:'),
value: n__('1 pipeline', '%d pipelines', this.counts.failed),
},
{
title: s__('PipelineCharts|Success ratio:'),
value: `${this.counts.successRatio}%`,
},
{
title: s__('PipelineCharts|Total duration:'),
value: this.totalDuration,
},
];
},
},
}; };
</script> </script>
<template> <template>
<ul> <ul>
<li> <template v-for="({ title, value }, index) in statistics">
<span>{{ s__('PipelineCharts|Total:') }}</span> <li :key="index">
<strong>{{ n__('1 pipeline', '%d pipelines', counts.total) }}</strong> <span>{{ title }}</span>
</li> <strong>{{ value }}</strong>
<li> </li>
<span>{{ s__('PipelineCharts|Successful:') }}</span> </template>
<strong>{{ n__('1 pipeline', '%d pipelines', counts.success) }}</strong>
</li>
<li>
<span>{{ s__('PipelineCharts|Failed:') }}</span>
<strong>{{ n__('1 pipeline', '%d pipelines', counts.failed) }}</strong>
</li>
<li>
<span>{{ s__('PipelineCharts|Success ratio:') }}</span>
<strong>{{ counts.successRatio }}%</strong>
</li>
</ul> </ul>
</template> </template>
...@@ -7,6 +7,7 @@ export default () => { ...@@ -7,6 +7,7 @@ export default () => {
countsFailed, countsFailed,
countsSuccess, countsSuccess,
countsTotal, countsTotal,
countsTotalDuration,
successRatio, successRatio,
timesChartLabels, timesChartLabels,
timesChartValues, timesChartValues,
...@@ -41,6 +42,7 @@ export default () => { ...@@ -41,6 +42,7 @@ export default () => {
success: countsSuccess, success: countsSuccess,
total: countsTotal, total: countsTotal,
successRatio, successRatio,
totalDuration: countsTotalDuration,
}, },
timesChartData: { timesChartData: {
labels: JSON.parse(timesChartLabels), labels: JSON.parse(timesChartLabels),
......
...@@ -193,6 +193,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -193,6 +193,7 @@ class Projects::PipelinesController < Projects::ApplicationController
@counts[:total] = @project.all_pipelines.count(:all) @counts[:total] = @project.all_pipelines.count(:all)
@counts[:success] = @project.all_pipelines.success.count(:all) @counts[:success] = @project.all_pipelines.success.count(:all)
@counts[:failed] = @project.all_pipelines.failed.count(:all) @counts[:failed] = @project.all_pipelines.failed.count(:all)
@counts[:total_duration] = @project.all_pipelines.total_duration
end end
def test_report def test_report
......
---
title: Add Total Duration to CI/CD Analytics Page
merge_request: 44863
author: Kev @KevSlashNull
type: added
...@@ -19402,6 +19402,9 @@ msgstr "" ...@@ -19402,6 +19402,9 @@ msgstr ""
msgid "PipelineCharts|Successful:" msgid "PipelineCharts|Successful:"
msgstr "" msgstr ""
msgid "PipelineCharts|Total duration:"
msgstr ""
msgid "PipelineCharts|Total:" msgid "PipelineCharts|Total:"
msgstr "" msgstr ""
......
...@@ -11,7 +11,6 @@ exports[`StatisticsList matches the snapshot 1`] = ` ...@@ -11,7 +11,6 @@ exports[`StatisticsList matches the snapshot 1`] = `
4 pipelines 4 pipelines
</strong> </strong>
</li> </li>
<li> <li>
<span> <span>
Successful: Successful:
...@@ -21,7 +20,6 @@ exports[`StatisticsList matches the snapshot 1`] = ` ...@@ -21,7 +20,6 @@ exports[`StatisticsList matches the snapshot 1`] = `
2 pipelines 2 pipelines
</strong> </strong>
</li> </li>
<li> <li>
<span> <span>
Failed: Failed:
...@@ -31,7 +29,6 @@ exports[`StatisticsList matches the snapshot 1`] = ` ...@@ -31,7 +29,6 @@ exports[`StatisticsList matches the snapshot 1`] = `
2 pipelines 2 pipelines
</strong> </strong>
</li> </li>
<li> <li>
<span> <span>
Success ratio: Success ratio:
...@@ -41,5 +38,14 @@ exports[`StatisticsList matches the snapshot 1`] = ` ...@@ -41,5 +38,14 @@ exports[`StatisticsList matches the snapshot 1`] = `
50% 50%
</strong> </strong>
</li> </li>
<li>
<span>
Total duration:
</span>
<strong>
00:01:56
</strong>
</li>
</ul> </ul>
`; `;
...@@ -3,6 +3,7 @@ export const counts = { ...@@ -3,6 +3,7 @@ export const counts = {
success: 2, success: 2,
total: 4, total: 4,
successRatio: 50, successRatio: 50,
totalDuration: 116158,
}; };
export const timesChartData = { export const timesChartData = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment