Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/statsmaster/files/usercounts.html

Issue 4811406654308352: Issue 763 - Count the number of users for the anti-adblock filters (Closed)
Patch Set: Created July 9, 2014, 1 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <title>User counter</title> 5 <title>User counter</title>
6 <style type="text/css"> 6 <style type="text/css">
7 form 7 form
8 { 8 {
9 display: inline; 9 display: inline;
10 } 10 }
(...skipping 30 matching lines...) Expand all
41 return result; 41 return result;
42 } 42 }
43 43
44 function formatDate(date) 44 function formatDate(date)
45 { 45 {
46 return zeroPad(date.getFullYear(), 4) + "-" + zeroPad(date.getMonth() + 1, 2) + "-" + zeroPad(date.getDate(), 2); 46 return zeroPad(date.getFullYear(), 4) + "-" + zeroPad(date.getMonth() + 1, 2) + "-" + zeroPad(date.getDate(), 2);
47 } 47 }
48 48
49 var curMonth = null; 49 var curMonth = null;
50 var curMonthFilters = null; 50 var curMonthFilters = null;
51 var curMonthAntiadblock = null;
51 var curMonthNotifications = null; 52 var curMonthNotifications = null;
52 53
53 function checkStats(data, fromDate, offset, callback) 54 function checkStats(data, fromDate, offset, callback)
54 { 55 {
55 var date = new Date(fromDate.getTime() + offset * MILLIS_IN_DAY); 56 var date = new Date(fromDate.getTime() + offset * MILLIS_IN_DAY);
56 57
57 function doDownload(url, descr, callback) 58 function doDownload(url, descr, callback)
58 { 59 {
59 var request = new XMLHttpRequest(); 60 var request = new XMLHttpRequest();
60 request.open("GET", url); 61 request.open("GET", url);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 108 }
108 } 109 }
109 } 110 }
110 111
111 var month = zeroPad(date.getFullYear(), 4) + zeroPad(date.getMonth() + 1, 2); 112 var month = zeroPad(date.getFullYear(), 4) + zeroPad(date.getMonth() + 1, 2);
112 if (month != curMonth) 113 if (month != curMonth)
113 { 114 {
114 doDownload("/raw/subscription/" + month + "/exceptionrules.txt.json", "a cceptable ads data for month " + month, function(json) 115 doDownload("/raw/subscription/" + month + "/exceptionrules.txt.json", "a cceptable ads data for month " + month, function(json)
115 { 116 {
116 curMonthFilters = json; 117 curMonthFilters = json;
117 doDownload("/raw/notification/" + month + "/notification.json.json", " notification data for month " + month, function(json) 118 doDownload("/raw/subscription/" + month + "/antiadblockfilters.txt.jso n", "anti-adblock data for month " + month, function(json)
118 { 119 {
119 curMonthNotifications = json; 120 curMonthAntiadblock = json;
120 curMonth = month; 121 doDownload("/raw/notification/" + month + "/notification.json.json", "notification data for month " + month, function(json)
121 doCheckStats(curMonthFilters, "acceptable"); 122 {
122 doCheckStats(curMonthNotifications, "total"); 123 curMonthNotifications = json;
123 callback(); 124 curMonth = month;
125 doCheckStats(curMonthFilters, "acceptable");
126 doCheckStats(curMonthAntiadblock, "antiadblock");
127 doCheckStats(curMonthNotifications, "total");
128 callback();
129 });
124 }); 130 });
125 }); 131 });
126 } 132 }
127 else 133 else
128 { 134 {
129 doCheckStats(curMonthFilters, "acceptable"); 135 doCheckStats(curMonthFilters, "acceptable");
136 doCheckStats(curMonthAntiadblock, "antiadblock");
130 doCheckStats(curMonthNotifications, "total"); 137 doCheckStats(curMonthNotifications, "total");
131 callback(); 138 callback();
132 } 139 }
133 } 140 }
134 141
135 function showResults(fromDate, data) 142 function showResults(fromDate, data)
136 { 143 {
137 function createCell(row, text) 144 function createCell(row, text)
138 { 145 {
139 var cell = document.createElement("td"); 146 var cell = document.createElement("td");
140 cell.appendChild(document.createTextNode(text)); 147 cell.appendChild(document.createTextNode(text));
141 row.appendChild(cell); 148 row.appendChild(cell);
142 } 149 }
143 150
144 var resultBody = document.getElementById("resultBody"); 151 var resultBody = document.getElementById("resultBody");
145 while (resultBody.lastChild) 152 while (resultBody.lastChild)
146 resultBody.removeChild(resultBody.lastChild); 153 resultBody.removeChild(resultBody.lastChild);
147 154
148 for (var i = 0; i < data.length; i++) 155 for (var i = 0; i < data.length; i++)
149 { 156 {
150 var date = new Date(fromDate.getTime() + i * MILLIS_IN_DAY); 157 var date = new Date(fromDate.getTime() + i * MILLIS_IN_DAY);
151 158
152 var row = document.createElement("tr"); 159 var row = document.createElement("tr");
153 createCell(row, date.toLocaleDateString()); 160 createCell(row, date.toLocaleDateString());
154 createCell(row, data[i]["1day total"].toLocaleString()); 161 createCell(row, data[i]["1day total"].toLocaleString());
162 createCell(row, data[i]["1day antiadblock"].toLocaleString());
155 createCell(row, data[i]["1day acceptable"].toLocaleString()); 163 createCell(row, data[i]["1day acceptable"].toLocaleString());
156 createCell(row, (100 - data[i]["1day acceptable"] / data[i]["1day total" ] * 100).toFixed(2) + "%"); 164 createCell(row, (100 - data[i]["1day acceptable"] / data[i]["1day total" ] * 100).toFixed(2) + "%");
157 createCell(row, data[i]["7day total"].toLocaleString()); 165 createCell(row, data[i]["7day total"].toLocaleString());
166 createCell(row, data[i]["7day antiadblock"].toLocaleString());
158 createCell(row, data[i]["7day acceptable"].toLocaleString()); 167 createCell(row, data[i]["7day acceptable"].toLocaleString());
159 createCell(row, (100 - data[i]["7day acceptable"] / data[i]["7day total" ] * 100).toFixed(2) + "%"); 168 createCell(row, (100 - data[i]["7day acceptable"] / data[i]["7day total" ] * 100).toFixed(2) + "%");
160 createCell(row, data[i]["30day total"].toLocaleString()); 169 createCell(row, data[i]["30day total"].toLocaleString());
170 createCell(row, data[i]["30day antiadblock"].toLocaleString());
161 createCell(row, data[i]["30day acceptable"].toLocaleString()); 171 createCell(row, data[i]["30day acceptable"].toLocaleString());
162 createCell(row, (100 - data[i]["30day acceptable"] / data[i]["30day tota l"] * 100).toFixed(2) + "%"); 172 createCell(row, (100 - data[i]["30day acceptable"] / data[i]["30day tota l"] * 100).toFixed(2) + "%");
163 resultBody.appendChild(row); 173 resultBody.appendChild(row);
164 } 174 }
165 175
166 document.getElementById("result").removeAttribute("hidden"); 176 document.getElementById("result").removeAttribute("hidden");
167 document.getElementById("wait").setAttribute("hidden", "hidden"); 177 document.getElementById("wait").setAttribute("hidden", "hidden");
168 } 178 }
169 179
170 function calculate() 180 function calculate()
(...skipping 23 matching lines...) Expand all
194 204
195 if (fromDate > toDate) 205 if (fromDate > toDate)
196 { 206 {
197 var tmp = fromDate; 207 var tmp = fromDate;
198 fromDate = toDate; 208 fromDate = toDate;
199 toDate = tmp; 209 toDate = tmp;
200 } 210 }
201 211
202 var data = []; 212 var data = [];
203 for (var d = fromDate; formatDate(d) <= formatDate(toDate); d = new Date(d .getTime() + MILLIS_IN_DAY)) 213 for (var d = fromDate; formatDate(d) <= formatDate(toDate); d = new Date(d .getTime() + MILLIS_IN_DAY))
204 data.push({"1day total": 0, "1day acceptable": 0, "7day total": 0, "7day acceptable": 0, "30day total": 0, "30day acceptable": 0}); 214 data.push({"1day total": 0, "1day antiadblock": 0, "1day acceptable": 0, "7day total": 0, "7day antiadblock": 0, "7day acceptable": 0, "30day total": 0, "30day antiadblock": 0, "30day acceptable": 0});
205 215
206 var offset = -30; 216 var offset = -30;
207 var callback = function() 217 var callback = function()
208 { 218 {
209 offset++; 219 offset++;
210 if (offset >= data.length) 220 if (offset >= data.length)
211 { 221 {
212 showResults(fromDate, data); 222 showResults(fromDate, data);
213 return; 223 return;
214 } 224 }
(...skipping 21 matching lines...) Expand all
236 <span class="spacer"></span> 246 <span class="spacer"></span>
237 <button type="submit">Calculate</button> 247 <button type="submit">Calculate</button>
238 </form> 248 </form>
239 </p> 249 </p>
240 <p id="wait" hidden> 250 <p id="wait" hidden>
241 Please wait, data is being fetched... 251 Please wait, data is being fetched...
242 </p> 252 </p>
243 <table id="result" hidden> 253 <table id="result" hidden>
244 <tr> 254 <tr>
245 <th rowspan="2">Date</th> 255 <th rowspan="2">Date</th>
246 <th colspan="3">1-day active users</th> 256 <th colspan="4">1-day active users</th>
247 <th colspan="3">7-day active users</th> 257 <th colspan="4">7-day active users</th>
248 <th colspan="3">30-day active users</th> 258 <th colspan="4">30-day active users</th>
249 </tr> 259 </tr>
250 <tr> 260 <tr>
251 <th>Total</th> 261 <th>Total</th>
262 <th>Anti-adblock filters</th>
252 <th>Acceptable ads</th> 263 <th>Acceptable ads</th>
253 <th>Opt-out rate</th> 264 <th>Opt-out rate</th>
254 <th>Total</th> 265 <th>Total</th>
266 <th>Anti-adblock filters</th>
267 <th>Acceptable ads</th>
268 <th>Opt-out rate</th>
269 <th>Total</th>
270 <th>Anti-adblock filters</th>
255 <th>Acceptable ads</th> 271 <th>Acceptable ads</th>
256 <th>Opt-out rate</th> 272 <th>Opt-out rate</th>
257 </tr> 273 </tr>
258 <tbody id="resultBody"> 274 <tbody id="resultBody">
259 </tbody> 275 </tbody>
260 </table> 276 </table>
261 </body> 277 </body>
262 </html> 278 </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