Skip to content

Commit

Permalink
Merge pull request #203 from mozilla/logviewer-step-result
Browse files Browse the repository at this point in the history
Bug 1043741 - Use the step result code for step failure determination
  • Loading branch information
camd committed Sep 24, 2014
2 parents e9db10f + bb14dab commit a7b95e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
24 changes: 12 additions & 12 deletions ui/js/controllers/logviewer.js
Expand Up @@ -33,21 +33,21 @@ logViewer.controller('LogviewerCtrl', [

$scope.$watch('artifact', function () {
if (!$scope.artifact) return;
if ($scope.totalErrors() > 0) {
$scope.showSuccessful = false;
} else {
$scope.showSuccessful = true;
}
$scope.showSuccessful = !$scope.hasFailedSteps();
});

$scope.totalErrors = function () {
return $scope.artifact.step_data.steps.reduce(function (prev, curr) {
if (prev.errors) {
return prev.errors.length;
$scope.hasFailedSteps = function () {
var steps = $scope.artifact.step_data.steps;
for (var i = 0; i < steps.length; i++) {
// We only recently generated step results as part of ingestion,
// so we have to check the results property is present.
// TODO: Remove this when the old data has expired, so long as
// other data submitters also provide a step result.
if ('result' in steps[i] && steps[i].result !== "success") {
return true;
}

return prev + curr.errors.length;
});
}
return false;
};

$scope.loadMore = function(bounds, element) {
Expand Down
2 changes: 1 addition & 1 deletion ui/js/directives/log_viewer_steps.js
Expand Up @@ -39,7 +39,7 @@ treeherder.directive('lvLogSteps', ['$timeout', '$q', function ($timeout, $q) {
scope.showSuccessful = !scope.showSuccessful;

var firstError = scope.artifact.step_data.steps.filter(function(step){
return step.errors && step.errors.length > 0;
return step.result && step.result !== "success";
})[0];

if (!firstError) return;
Expand Down
8 changes: 4 additions & 4 deletions ui/partials/logviewer/lvLogSteps.html
Expand Up @@ -2,9 +2,9 @@
<div ng-repeat="step in artifact.step_data.steps"
ng-click="displayLog(step)"
ng-class="{'selected': (displayedStep.order === step.order),
'btn-success': (step.error_count === 0),
'btn-warning': (step.error_count > 0)}"
ng-if="showSuccessful === true || step.error_count !== 0"
'btn-success': (step.result === 'success'),
'btn-warning': (step.result !== 'success')}"
ng-if="showSuccessful === true || step.result !== 'success'"
class="btn btn-block logviewer-step clearfix"
order="{{step.order}}">
<span class="pull-left clearfix">
Expand Down Expand Up @@ -43,7 +43,7 @@
</a>
</div>

<div ng-if="artifact && totalErrors() !== 0"
<div ng-if="artifact && hasFailedSteps()"
class="logviewer-stepbar">
<input type="checkbox"
ng-model="showSuccessful"
Expand Down

0 comments on commit a7b95e5

Please sign in to comment.