1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This Source Code Form is "Incompatible With Secondary Licenses", as
* defined by the Mozilla Public License, v. 2.0.
*/
$(function() {
'use strict';
function getOrangeCount(data) {
let days = [];
let total = 0;
data.forEach(entry => {
let failureCount = entry["failure_count"];
days.push(failureCount);
total += failureCount;
});
displayGraph(days);
displayCount(total);
}
function displayGraph(dayCounts) {
var max = dayCounts.reduce(function(max, count) {
return count > max ? count : max;
});
$('#orange-graph')
.attr('title', 'failures over the past week, max in a day: ' + max)
.show();
var opts = {
"percentage_lines":[0.25, 0.5, 0.75],
"fill_between_percentage_lines": false,
"left_padding": 0,
"right_padding": 0,
"top_padding": 0,
"bottom_padding": 0,
"background": "#D0D0D0",
"stroke": "#000000",
"percentage_fill_color": "#CCCCFF",
"scale_from_zero": true,
};
new Sparkline('orange-graph', dayCounts, opts).draw();
}
function displayCount(count) {
$('#orange-count').text(count + ' failures on trunk in the past week');
}
function orangify() {
let $orangeCount = $('#orange-count');
let queryParams = $.param({
bug: $orangeCount.data('bug-id'),
startday: $orangeCount.data('date-start'),
endday: $orangeCount.data('date-end'),
tree: 'trunk'
});
let request = {
dataType: "json",
url: `https://treeherder.mozilla.org/api/failurecount/?${queryParams}`
};
$orangeCount.text('Loading...').show();
$.ajax(request)
.done(function(data) {
getOrangeCount(data);
})
.fail(function() {
$orangeCount.text('Unable to load OrangeFactor at this time.');
});
}
orangify();
});
|