Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 function getSomeData() { | |
| 23 } | |
|
borenet
2014/03/13 16:19:36
This is empty and looks unused... what's it for?
humper
2014/03/13 16:52:00
It's for making sure you actually reviewed the cod
| |
| 24 | |
| 25 function getBugData(callback) { | |
|
epoger
2014/03/13 16:18:07
Please add a comment indicating why this complicat
borenet
2014/03/13 16:20:48
+1
humper
2014/03/13 16:52:00
Done.
| |
| 26 $.get( url, ph_params, function( data ) { | |
| 27 totalResults = data.totalResults | |
| 28 all_items = all_items.concat(data.items); | |
| 29 $("#stats").text("Received " + all_items.length + | |
| 30 " total Skia bugs of " + (totalResults-1) + "." ); | |
| 31 if (all_items.length == totalResults - 1) { | |
| 32 callback(); | |
| 33 } else { | |
| 34 ph_params['startIndex'] = all_items.length + 1; | |
| 35 getBugData(callback); | |
| 36 } | |
| 37 }); | |
| 38 } | |
| 18 | 39 |
| 19 function drawChart() { | 40 function drawChart() { |
| 20 var bug_data = []; | 41 var bug_data = []; |
| 21 | |
| 22 $.get( url, ph_params, function( data ) { | |
| 23 | 42 |
| 43 getBugData(function() { | |
| 24 | 44 |
| 25 /* Data comes back from the Project Hosting API in JSON format like: | 45 /* Data comes back from the Project Hosting API in JSON format like: |
| 26 | 46 |
| 27 { | 47 { |
| 28 "totalResults": 1057, | 48 "totalResults": 1057, |
| 29 "items": [ | 49 "items": [ |
| 30 { | 50 { |
| 31 "published": "2008-12-23T18:57:06.000Z", | 51 "published": "2008-12-23T18:57:06.000Z", |
| 32 "closed": "2009-04-23T17:12:54.000Z" | 52 "closed": "2009-04-23T17:12:54.000Z" |
| 33 }, | 53 }, |
| 34 { | 54 { |
| 35 "published": "2008-12-23T18:58:08.000Z", | 55 "published": "2008-12-23T18:58:08.000Z", |
| 36 "closed": "2010-04-15T17:28:52.000Z" | 56 "closed": "2010-04-15T17:28:52.000Z" |
| 37 }, | 57 }, |
| 38 ... | 58 ... |
| 39 } | 59 } |
| 40 | 60 |
| 41 if the bug is still open, there will simply not be a 'closed' | 61 if the bug is still open, there will simply not be a 'closed' |
| 42 attribute on the item. | 62 attribute on the item. |
| 43 | 63 |
| 44 */ | 64 */ |
| 45 | |
| 46 | 65 |
| 47 // turn this into a list of [ date, +1/-1 ] pairs indicating | 66 |
| 67 // turn this into a list of [ date, +1/-1 ] pairs indicating | |
| 48 // whether or not we added or subtracted a bug on that day. | 68 // whether or not we added or subtracted a bug on that day. |
| 49 // Need this intermediate step because the list of actions | 69 // Need this intermediate step because the list of actions |
| 50 // are only sorted on publication date, but the close date | 70 // are only sorted on publication date, but the close date |
| 51 // can be any time in the future. | 71 // can be any time in the future. |
| 52 | 72 |
| 53 actions = []; | 73 actions = []; |
| 54 for (var i = 0 ; i < data.items.length; i++) { | 74 for (var i = 0 ; i < all_items.length; i++) { |
| 55 var publish = new Date(data.items[i].published); | 75 var publish = new Date(all_items[i].published); |
| 56 actions.push( [publish, 1] ); | 76 actions.push( [publish, 1] ); |
| 57 if (data.items[i].closed ) { | 77 if (all_items[i].closed ) { |
| 58 var closed = new Date(data.items[i].closed); | 78 var closed = new Date(all_items[i].closed); |
| 59 actions.push( [closed,-1] ); | 79 actions.push( [closed,-1] ); |
| 60 } | 80 } |
| 61 } | 81 } |
| 62 | 82 |
| 63 // now that opening and closing bugs are on equal footing, | 83 // now that opening and closing bugs are on equal footing, |
| 64 // we can sort the action array by the date. | 84 // we can sort the action array by the date. |
| 65 | 85 |
| 66 actions.sort( function(a,b) { return a[0] - b[0]; } ); | 86 actions.sort( function(a,b) { return a[0] - b[0]; } ); |
| 67 | 87 |
| 68 // convert the action array to a running total, and format | 88 // convert the action array to a running total, and format |
| 69 // it for the google visualization API while we're at it. | 89 // it for the google visualization API while we're at it. |
| 70 | 90 |
| 71 var bug_count = 0; | 91 var bug_count = 0; |
| 72 for (var i = 0 ; i < actions.length; i++) { | 92 for (var i = 0 ; i < actions.length; i++) { |
| 73 bug_count += actions[i][1]; | 93 bug_count += actions[i][1]; |
| 74 bug_data.push( {c: [{v: actions[i][0]}, {v: bug_count}]} ); | 94 bug_data.push( {c: [{v: actions[i][0]}, {v: bug_count}]} ); |
| 75 } | 95 } |
| 76 $("#stats").text("Found " + data.totalResults + | 96 $("#stats").text("Found " + (totalResults-1) + |
| 77 " total Skia bugs, with " + bug_count + | 97 " total Skia bugs, with " + bug_count + |
| 78 " remaining open." ); | 98 " remaining open." ); |
| 79 | 99 |
| 80 var data_table_init = { | 100 var data_table_init = { |
| 81 'cols': [ | 101 'cols': [ |
| 82 { | 102 { |
| 83 'label': 'Time', | 103 'label': 'Time', |
| 84 'type': 'datetime' | 104 'type': 'datetime' |
| 85 }, | 105 }, |
| 86 { | 106 { |
| 87 'label': 'Number of open Skia bugs', | 107 'label': 'Number of open Skia bugs', |
| 88 'type': 'number' | 108 'type': 'number' |
| 89 } | 109 } |
| 90 ], | 110 ], |
| 91 'rows': bug_data | 111 'rows': bug_data |
| 92 }; | 112 }; |
| 93 | 113 |
| 94 var data_table = new google.visualization.DataTable(data_table_init); | 114 var data_table = new google.visualization.DataTable(data_table_init); |
| 95 | 115 |
| 96 var options = { | 116 var options = { |
| 97 'title': 'Number of open Skia bugs', | 117 'title': 'Number of open Skia bugs', |
| 98 'width': 1024, | 118 'width': 1024, |
| 99 'height': 768 | 119 'height': 768 |
| 100 }; | 120 }; |
| 101 | 121 |
| 102 var graph_container = document.getElementById('graph'); | 122 var graph_container = document.getElementById('graph'); |
| 103 var graph = new google.visualization.LineChart(graph_container); | 123 var graph = new google.visualization.LineChart(graph_container); |
| 104 graph.draw(data_table,options); | 124 graph.draw(data_table,options); |
| 105 }); | 125 }); |
| 106 } | 126 } |
| 107 </script> | 127 </script> |
| 108 | 128 |
| 109 <style> | 129 <style> |
| 110 body { | 130 body { |
| 111 font-size: 24pt; | 131 font-size: 24pt; |
| 112 text-align: center; | 132 text-align: center; |
| 113 font-family: Verdana, Arial, Helvetica, sans-serif; | 133 font-family: Verdana, Arial, Helvetica, sans-serif; |
| 114 } | 134 } |
| 115 </style> | 135 </style> |
| 116 | 136 |
| 117 <title>Skia bug motivator</title> | 137 <title>Skia bug motivator</title> |
| 118 </head> | 138 </head> |
| 119 <body> | 139 <body> |
| 120 <div id="results_wrapper"> | 140 <div id="results_wrapper"> |
| 121 Retrieving Skia bug information... | 141 Retrieving Skia bug information... |
| 122 <div id="stats"></div> | 142 <div id="stats"></div> |
| 123 <div id="graph"></div> | 143 <div id="graph"></div> |
| 124 </div> | 144 </div> |
| 125 </body> | 145 </body> |
| 126 </html> | 146 </html> |
| OLD | NEW |