Skip to content

Commit 99982de

Browse files
author
OpenShift Bot
committed
Merge pull request #8804 from spadgett/build-chart-deleted-builds
Merged by openshift-bot
2 parents 8f8abdb + 99a271f commit 99982de

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

app/scripts/directives/buildTrendsChart.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ angular.module('openshiftConsole')
99
},
1010
templateUrl: 'views/_build-trends-chart.html',
1111
link: function($scope) {
12-
var buildByNumber;
12+
var data;
1313
var completePhases = ['Complete', 'Failed', 'Cancelled', 'Error'];
1414

1515
// Minimum number of builds to show.
@@ -67,11 +67,12 @@ angular.module('openshiftConsole')
6767
},
6868
tick: {
6969
culling: true,
70-
fit: true,
7170
format: function(x) {
72-
return '#' + x;
73-
}
74-
}
71+
return '#' + data.json[x].buildNumber;
72+
},
73+
width: 30
74+
},
75+
type: 'category'
7576
},
7677
y: {
7778
label: {
@@ -107,9 +108,9 @@ angular.module('openshiftConsole')
107108
tooltip: {
108109
format: {
109110
title: function(x) {
110-
var build = buildByNumber[x];
111-
var startTimestamp = getStartTimestsamp(build);
112-
return '#' + x + ' (' + moment(startTimestamp).fromNow() + ')';
111+
var json = data.json[x];
112+
var startTimestamp = getStartTimestsamp(json.build);
113+
return '#' + json.buildNumber + ' (' + moment(startTimestamp).fromNow() + ')';
113114
}
114115
}
115116
},
@@ -130,7 +131,7 @@ angular.module('openshiftConsole')
130131
}
131132
},
132133
onclick: function(d) {
133-
var build = buildByNumber[d.x];
134+
var build = data.json[d.x].build;
134135
var url = $filter('navigateResourceURL')(build);
135136
if (url) {
136137
$rootScope.$apply(function() {
@@ -199,8 +200,7 @@ angular.module('openshiftConsole')
199200

200201
var update = function() {
201202
// Keep a map of builds by number so we can find the build later when a data point is clicked.
202-
buildByNumber = {};
203-
var data = {
203+
data = {
204204
json: [],
205205
keys: {
206206
x: 'buildNumber'
@@ -222,18 +222,19 @@ angular.module('openshiftConsole')
222222

223223
var buildData = {
224224
buildNumber: buildNumber,
225-
phase: build.status.phase
225+
phase: build.status.phase,
226+
build: build
226227
};
227228
buildData[build.status.phase] = duration;
228229
data.json.push(buildData);
229-
buildByNumber[buildNumber] = build;
230+
});
231+
232+
data.json.sort(function(a, b) {
233+
return a.buildNumber - b.buildNumber;
230234
});
231235

232236
// Show only the last 50 builds.
233237
if (data.json.length > 50) {
234-
data.json.sort(function(a, b) {
235-
return a.buildNumber - b.buildNumber;
236-
});
237238
data.json = data.json.slice(data.json.length - 50);
238239
}
239240

0 commit comments

Comments
 (0)