Skip to content

Commit

Permalink
showing number of failing and working budgets sitespeedio#576
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Feb 12, 2015
1 parent d9568f6 commit 6e83b17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/tests/testRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ TestRenderer.prototype.render = function(cb) {
self.log.log('error', 'Error rendering budget ' + err);
cb(err);
} else {
var noFailing = 0;
var noWorking = 0;
if (self.config.budget) {
// structure the data per failing types
var failingPerType = {};
Expand All @@ -360,19 +362,24 @@ TestRenderer.prototype.render = function(cb) {
self.config.budgetResult.forEach(function(result) {
if (!result.isOk) {
isFailing = true;
noFailing += 1;
if (failingPerType[result.id]) {
failingPerType[result.id].push(result);
} else {
failingPerType[result.id] = [];
failingPerType[result.id].push(result);
}
} else if (result.isOk) {
noWorking += 1;
}
});

var renderData = {
'failing': failingPerType,
'isFailing': isFailing,
'budget': self.config.budgetResult,
'noFailing': noFailing,
'noWorking': noWorking,
'config': self.config,
'pageMeta': {
'title': 'The result of the performance budget',
Expand Down
6 changes: 3 additions & 3 deletions templates/budget.hb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div class="row">
<div class="col-lg-12">
<h2>The budget</h2>
<p>These are the results from the performance budget.</p>
<p>These are the results from the performance budget. We got {{noFailing}} failing and {{noWorking}} working.</p>

{{#if isFailing}}
<h3>Failing budgets</h3>
<h3>Failing budgets [{{noFailing}}]</h3>
{{#each failing}}
{{#each this}}
{{#if @first}}
Expand All @@ -23,7 +23,7 @@
<h3>No failing budgets</h3>
{{/if}}

<h3>Working budgets</h3>
<h3>Working budgets [{{noWorking}}]</h3>
<ul>
{{#each budget}}
{{#if isOk}}
Expand Down

0 comments on commit 6e83b17

Please sign in to comment.