Commit 74abc775 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'adriel-add-deployment-data' into 'master'

Add deployment data to metrics graphs

See merge request gitlab-org/gitlab-ce!24650
parents 4dc45702 aa5d5162
...@@ -33,6 +33,11 @@ export default { ...@@ -33,6 +33,11 @@ export default {
type: Number, type: Number,
required: true, required: true,
}, },
deploymentData: {
type: Array,
required: false,
default: () => [],
},
alertData: { alertData: {
type: Object, type: Object,
required: false, required: false,
...@@ -79,6 +84,43 @@ export default { ...@@ -79,6 +84,43 @@ export default {
legend: { legend: {
formatter: this.xAxisLabel, formatter: this.xAxisLabel,
}, },
series: this.scatterSeries,
};
},
earliestDatapoint() {
return Object.values(this.chartData).reduce((acc, data) => {
const [[timestamp]] = data.sort(([a], [b]) => {
if (a < b) {
return -1;
}
return a > b ? 1 : 0;
});
return timestamp < acc || acc === null ? timestamp : acc;
}, null);
},
recentDeployments() {
return this.deploymentData.reduce((acc, deployment) => {
if (deployment.created_at >= this.earliestDatapoint) {
acc.push({
id: deployment.id,
createdAt: deployment.created_at,
sha: deployment.sha,
commitUrl: `${this.projectPath}/commit/${deployment.sha}`,
tag: deployment.tag,
tagUrl: deployment.tag ? `${this.tagsPath}/${deployment.ref.name}` : null,
ref: deployment.ref.name,
showDeploymentFlag: false,
});
}
return acc;
}, []);
},
scatterSeries() {
return {
type: 'scatter',
data: this.recentDeployments.map(deployment => [deployment.createdAt, 0]),
}; };
}, },
xAxisLabel() { xAxisLabel() {
......
...@@ -190,6 +190,7 @@ export default { ...@@ -190,6 +190,7 @@ export default {
v-for="(graphData, graphIndex) in groupData.metrics" v-for="(graphData, graphIndex) in groupData.metrics"
:key="graphIndex" :key="graphIndex"
:graph-data="graphData" :graph-data="graphData"
:deployment-data="store.deploymentData"
:alert-data="getGraphAlerts(graphData.id)" :alert-data="getGraphAlerts(graphData.id)"
:container-width="elWidth" :container-width="elWidth"
group-id="monitor-area-chart" group-id="monitor-area-chart"
......
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