diff options
-rw-r--r-- | js/main.js | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -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); |