Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: bug_graphs.html

Issue 199243002: fix bug graph -- it was only getting the last 1000 entries despite my (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Nits / comments / remove dead code Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jq uery/1.9.0/jquery.min.js"></script> 3 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jq uery/1.9.0/jquery.min.js"></script>
4 <script type="text/javascript" src="https://www.google.com/jsapi"></script> 4 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 var url = "https://www.googleapis.com/projecthosting/v2/projects/skia/issu es"; 6 var url = "https://www.googleapis.com/projecthosting/v2/projects/skia/issu es";
7 7
8 var ph_params = { 8 var ph_params = {
9 sort: 'items(published)', 9 sort: 'items(published)',
10 fields: 'items(published,closed),totalResults', 10 fields: 'items(published,closed),totalResults',
11 maxResults: 99999, 11 maxResults: 9999,
12 key: 'AIzaSyDq0bq2zkLR1WfmmGihHU6Vf6nG4msE-io', 12 key: 'AIzaSyDq0bq2zkLR1WfmmGihHU6Vf6nG4msE-io',
13 startIndex: 0
13 }; 14 };
14 15
15 google.load('visualization', '1', {packages:['corechart']}); 16 google.load('visualization', '1', {packages:['corechart']});
16 google.setOnLoadCallback( drawChart ); 17 google.setOnLoadCallback( drawChart );
17 18
19 all_items = [];
20 var totalResults;
21
22 // The bug database API may not return all the requested bugs in a single call.
23 // (data.totalResults will return the total number of bugs that meet the
24 // request parameters, but data.items may only include a subset.)
25 // Keep calling back to the API, and appending results to all_items, until
26 // we get as many results as promised in data.totalResults (which is,
27 // of course, actually a 1-indexed array index for the last value, not the
28 // actual number of results. Hence the minus-ones.
29
30 function getBugData(callback) {
31 $.get( url, ph_params, function( data ) {
32 totalResults = data.totalResults
33 all_items = all_items.concat(data.items);
34 $("#stats").text("Received " + all_items.length +
35 " total Skia bugs of " + (totalResults-1) + "." );
36 if (all_items.length == totalResults - 1) {
37 callback();
38 } else {
39 ph_params['startIndex'] = all_items.length + 1;
40 getBugData(callback);
41 }
42 });
43 }
18 44
19 function drawChart() { 45 function drawChart() {
20 var bug_data = []; 46 var bug_data = [];
21
22 $.get( url, ph_params, function( data ) {
23 47
48 getBugData(function() {
24 49
25 /* Data comes back from the Project Hosting API in JSON format like: 50 /* Data comes back from the Project Hosting API in JSON format like:
26 51
27 { 52 {
28 "totalResults": 1057, 53 "totalResults": 1057,
29 "items": [ 54 "items": [
30 { 55 {
31 "published": "2008-12-23T18:57:06.000Z", 56 "published": "2008-12-23T18:57:06.000Z",
32 "closed": "2009-04-23T17:12:54.000Z" 57 "closed": "2009-04-23T17:12:54.000Z"
33 }, 58 },
34 { 59 {
35 "published": "2008-12-23T18:58:08.000Z", 60 "published": "2008-12-23T18:58:08.000Z",
36 "closed": "2010-04-15T17:28:52.000Z" 61 "closed": "2010-04-15T17:28:52.000Z"
37 }, 62 },
38 ... 63 ...
39 } 64 }
40 65
41 if the bug is still open, there will simply not be a 'closed' 66 if the bug is still open, there will simply not be a 'closed'
42 attribute on the item. 67 attribute on the item.
43 68
44 */ 69 */
45
46 70
47 // turn this into a list of [ date, +1/-1 ] pairs indicating 71
72 // turn this into a list of [ date, +1/-1 ] pairs indicating
48 // whether or not we added or subtracted a bug on that day. 73 // whether or not we added or subtracted a bug on that day.
49 // Need this intermediate step because the list of actions 74 // Need this intermediate step because the list of actions
50 // are only sorted on publication date, but the close date 75 // are only sorted on publication date, but the close date
51 // can be any time in the future. 76 // can be any time in the future.
52 77
53 actions = []; 78 actions = [];
54 for (var i = 0 ; i < data.items.length; i++) { 79 for (var i = 0 ; i < all_items.length; i++) {
55 var publish = new Date(data.items[i].published); 80 var publish = new Date(all_items[i].published);
56 actions.push( [publish, 1] ); 81 actions.push( [publish, 1] );
57 if (data.items[i].closed ) { 82 if (all_items[i].closed ) {
58 var closed = new Date(data.items[i].closed); 83 var closed = new Date(all_items[i].closed);
59 actions.push( [closed,-1] ); 84 actions.push( [closed,-1] );
60 } 85 }
61 } 86 }
62 87
63 // now that opening and closing bugs are on equal footing, 88 // now that opening and closing bugs are on equal footing,
64 // we can sort the action array by the date. 89 // we can sort the action array by the date.
65 90
66 actions.sort( function(a,b) { return a[0] - b[0]; } ); 91 actions.sort( function(a,b) { return a[0] - b[0]; } );
67 92
68 // convert the action array to a running total, and format 93 // convert the action array to a running total, and format
69 // it for the google visualization API while we're at it. 94 // it for the google visualization API while we're at it.
70 95
71 var bug_count = 0; 96 var bug_count = 0;
72 for (var i = 0 ; i < actions.length; i++) { 97 for (var i = 0 ; i < actions.length; i++) {
73 bug_count += actions[i][1]; 98 bug_count += actions[i][1];
74 bug_data.push( {c: [{v: actions[i][0]}, {v: bug_count}]} ); 99 bug_data.push( {c: [{v: actions[i][0]}, {v: bug_count}]} );
75 } 100 }
76 $("#stats").text("Found " + data.totalResults + 101 $("#stats").text("Found " + (totalResults-1) +
77 " total Skia bugs, with " + bug_count + 102 " total Skia bugs, with " + bug_count +
78 " remaining open." ); 103 " remaining open." );
79 104
80 var data_table_init = { 105 var data_table_init = {
81 'cols': [ 106 'cols': [
82 { 107 {
83 'label': 'Time', 108 'label': 'Time',
84 'type': 'datetime' 109 'type': 'datetime'
85 }, 110 },
86 { 111 {
87 'label': 'Number of open Skia bugs', 112 'label': 'Number of open Skia bugs',
88 'type': 'number' 113 'type': 'number'
89 } 114 }
90 ], 115 ],
91 'rows': bug_data 116 'rows': bug_data
92 }; 117 };
93 118
94 var data_table = new google.visualization.DataTable(data_table_init); 119 var data_table = new google.visualization.DataTable(data_table_init);
95 120
96 var options = { 121 var options = {
97 'title': 'Number of open Skia bugs', 122 'title': 'Number of open Skia bugs',
98 'width': 1024, 123 'width': 1024,
99 'height': 768 124 'height': 768
100 }; 125 };
101 126
102 var graph_container = document.getElementById('graph'); 127 var graph_container = document.getElementById('graph');
103 var graph = new google.visualization.LineChart(graph_container); 128 var graph = new google.visualization.LineChart(graph_container);
104 graph.draw(data_table,options); 129 graph.draw(data_table,options);
105 }); 130 });
106 } 131 }
107 </script> 132 </script>
108 133
109 <style> 134 <style>
110 body { 135 body {
111 font-size: 24pt; 136 font-size: 24pt;
112 text-align: center; 137 text-align: center;
113 font-family: Verdana, Arial, Helvetica, sans-serif; 138 font-family: Verdana, Arial, Helvetica, sans-serif;
114 } 139 }
115 </style> 140 </style>
116 141
117 <title>Skia bug motivator</title> 142 <title>Skia bug motivator</title>
118 </head> 143 </head>
119 <body> 144 <body>
120 <div id="results_wrapper"> 145 <div id="results_wrapper">
121 Retrieving Skia bug information... 146 Open Skia bugs over time
122 <div id="stats"></div> 147 <div id="stats">Gettings bugs, please wait...</div>
123 <div id="graph"></div> 148 <div id="graph"></div>
124 </div> 149 </div>
125 </body> 150 </body>
126 </html> 151 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698