summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/main.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/js/main.js b/js/main.js
index 6854273..74f0cf2 100644
--- a/js/main.js
+++ b/js/main.js
@@ -18,12 +18,23 @@ app.controller('VisualisationController', ['$scope', '$http',
$http.get('http://ciat.baserock.org:8010/json/builders')
.then(function(builders) {
angular.forEach(builders.data, function(value, key) {
- var lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1];
- var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' +
- key + '/builds/' + lastBuildID;
+ var lastBuildID = -1;
+ if (value.state === 'building') {
+ lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 2];
+ } else {
+ lastBuildID = value.cachedBuilds[value.cachedBuilds.length - 1];
+ }
+
+ var previous = null;
+ if (lastBuildID != -1) {
+ var buildsPath = 'http://ciat.baserock.org:8010/json/builders/' +
+ key + '/builds/' + lastBuildID;
+ previous = $http.get(buildsPath).then(formatBuild);
+ }
+
var step = {
name: key,
- lastBuild: $http.get(buildsPath).then(formatBuild),
+ lastBuild: previous,
data: value
}
$scope.steps.push(step);