Added a couple of checkbox to choose which builds are included.

This commit is contained in:
Georges Dupéron 2016-07-30 17:14:51 +02:00
parent 9749c85ca3
commit 2b1285652b
2 changed files with 14 additions and 3 deletions

View File

@ -8,9 +8,15 @@
<body> <body>
<h1>Travis CI build stats</h1> <h1>Travis CI build stats</h1>
<form> <form>
<label>Repository:</label> <label for="repo-name">Repository:</label>
<input id="repo-name" type="text" placeholder="owner/repo" /> <input id="repo-name" type="text" placeholder="owner/repo" />
<input class="button" type="submit" value="Render" /> <input class="button" type="submit" value="Render" />
<br />
<input id="include-failed" type="checkbox" checked="checked" />
<label for="include-failed">Include failed builds</label>
<br />
<input id="only-master" type="checkbox" />
<label for="only-master">Only master branch</label>
</form> </form>
<div class="column"> <div class="column">

View File

@ -140,6 +140,8 @@ function getBuildDate(build) {
function updateChart() { function updateChart() {
var repoName = document.getElementById('repo-name').value; var repoName = document.getElementById('repo-name').value;
var includeFailed = document.getElementById('include-failed').checked;
var onlyMaster = document.getElementById('only-master').checked;
// need at least "a/a" // need at least "a/a"
if (repoName.length < 3) { if (repoName.length < 3) {
@ -148,7 +150,7 @@ function updateChart() {
var baseUrl = 'https://travis-ci.org/' + repoName + '/builds/'; var baseUrl = 'https://travis-ci.org/' + repoName + '/builds/';
var buildsUrl = 'https://api.travis-ci.org/repos/' + repoName + '/builds?event_type=push'; var buildsUrl = 'https://api.travis-ci.org/repos/' + repoName + '/builds'; // ?event_type=push';
var builds = []; var builds = [];
@ -181,7 +183,10 @@ function updateChart() {
curOldestBuild = buildNr; curOldestBuild = buildNr;
} }
if (/*build.branch !== 'master' ||*/ build.state !== 'finished') { if ((onlyMaster && build.branch !== 'master')
|| (build.state !== 'finished')
|| (!includeFailed && build.result !== 0)
|| (build.event_type != "push" && build.event_type != "cron")) {
return; return;
} }