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

Delta Between Two Patch Sets: sitescripts/logs/template/subscription.html

Issue 9503001: Subscription stats: Make sure there can be no division by zero errors (Closed)
Left Patch Set: Created March 1, 2013, 8:05 a.m.
Right Patch Set: Fixed the issue in all the relevant places now Created March 1, 2013, 8:29 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « .hgsubstate ('k') | sitescripts/logs/template/subscriptionOverview.html » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 <!-- 1 <!--
2 - This file is part of the Adblock Plus web scripts, 2 - This file is part of the Adblock Plus web scripts,
3 - Copyright (C) 2006-2012 Eyeo GmbH 3 - Copyright (C) 2006-2012 Eyeo GmbH
4 - 4 -
5 - Adblock Plus is free software: you can redistribute it and/or modify 5 - Adblock Plus is free software: you can redistribute it and/or modify
6 - it under the terms of the GNU General Public License version 3 as 6 - it under the terms of the GNU General Public License version 3 as
7 - published by the Free Software Foundation. 7 - published by the Free Software Foundation.
8 - 8 -
9 - Adblock Plus is distributed in the hope that it will be useful, 9 - Adblock Plus is distributed in the hope that it will be useful,
10 - but WITHOUT ANY WARRANTY; without even the implied warranty of 10 - but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 <td align="right">&nbsp;</td> 129 <td align="right">&nbsp;</td>
130 <td align="right">{{totalBandwidth|bytes}}</td> 130 <td align="right">{{totalBandwidth|bytes}}</td>
131 </tr> 131 </tr>
132 </table> 132 </table>
133 </div> 133 </div>
134 134
135 <div class="block_title">Days of week</div> 135 <div class="block_title">Days of week</div>
136 <div class="block"> 136 <div class="block">
137 <table align="center" style="margin-bottom: 20px;"> 137 <table align="center" style="margin-bottom: 20px;">
138 <tr align="bottom"> 138 <tr align="bottom">
139 {%- set maxHits, maxBandwidth = weekday|max(attribute='hits'),weekday| max(attribute='bandwidth') %} 139 {%- set maxHits = weekday|max(attribute='hits')|ensuremin(1) %}
140 {%- set maxBandwidth = weekday|max(attribute='bandwidth')|ensuremin(1) %}
140 {%- for info in weekday %} 141 {%- for info in weekday %}
141 <td align="center" style="vertical-align: bottom;"> 142 <td align="center" style="vertical-align: bottom;">
142 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px"></div> 143 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px"></div>
143 {{- '' -}} 144 {{- '' -}}
144 <div class="bandwidthChart vertical" alt="Bandwidth: {{info.bandwidt h|bytes}}"" title="Bandwidth: {{info.bandwidth|bytes}}" style="height: {{(info.b andwidth / maxBandwidth * 100)|round(method='ceil')|int}}px"></div> 145 <div class="bandwidthChart vertical" alt="Bandwidth: {{info.bandwidt h|bytes}}"" title="Bandwidth: {{info.bandwidth|bytes}}" style="height: {{(info.b andwidth / maxBandwidth * 100)|round(method='ceil')|int}}px"></div>
145 </td> 146 </td>
146 {%- endfor %} 147 {%- endfor %}
147 </tr> 148 </tr>
148 <tr> 149 <tr>
149 {%- for info in weekday %} 150 {%- for info in weekday %}
150 <td align="center"{% if info.id > 4 %} class="special"{% endif %}> 151 <td align="center"{% if info.id > 4 %} class="special"{% endif %}>
151 {{info.id|weekday}} 152 {{info.id|weekday}}
152 </td> 153 </td>
153 {%- endfor %} 154 {%- endfor %}
154 </tr> 155 </tr>
155 </table> 156 </table>
156 157
157 <table align="center"> 158 <table align="center">
158 <tr> 159 <tr>
159 <th bgcolor="#ECECEC">Day</th> 160 <th bgcolor="#ECECEC">Day</th>
160 <th bgcolor="#66DDEE" colspan="2">Hits</th> 161 <th bgcolor="#66DDEE" colspan="2">Hits</th>
161 <th bgcolor="#2EA495">Bandwidth</th> 162 <th bgcolor="#2EA495">Bandwidth</th>
162 </tr> 163 </tr>
163 {%- set totalHits = weekday|sum(attribute='hits') %} 164 {%- set totalHits = weekday|sum(attribute='hits')|ensuremin(1) %}
164 {%- set totalBandwidth = weekday|sum(attribute='bandwidth') %} 165 {%- set totalBandwidth = weekday|sum(attribute='bandwidth')|ensuremin(1) %}
165 {%- for info in weekday %} 166 {%- for info in weekday %}
166 <tr{% if info.id > 4 %} class="special"{% endif %}> 167 <tr{% if info.id > 4 %} class="special"{% endif %}>
167 <td>{{info.id|weekday}}</td> 168 <td>{{info.id|weekday}}</td>
168 <td align="right">{{info.hits}}</td> 169 <td align="right">{{info.hits}}</td>
169 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 170 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
170 <td align="right">{{info.bandwidth|bytes}}</td> 171 <td align="right">{{info.bandwidth|bytes}}</td>
171 </tr> 172 </tr>
172 {%- endfor %} 173 {%- endfor %}
173 </table> 174 </table>
174 </div> 175 </div>
175 176
176 <div class="block_title">Hours</div> 177 <div class="block_title">Hours</div>
177 <div class="block"> 178 <div class="block">
178 <table align="center" style="margin-bottom: 20px;"> 179 <table align="center" style="margin-bottom: 20px;">
179 <tr align="bottom"> 180 <tr align="bottom">
180 {%- set maxHits, maxBandwidth = hour|max(attribute='hits'),hour|max(at tribute='bandwidth') %} 181 {%- set maxHits = hour|max(attribute='hits')|ensuremin(1) %}
182 {%- set maxBandwidth = hour|max(attribute='bandwidth')|ensuremin(1) %}
181 {%- for info in hour %} 183 {%- for info in hour %}
182 <td align="center" style="vertical-align: bottom;"> 184 <td align="center" style="vertical-align: bottom;">
183 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px;"></div> 185 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px;"></div>
184 {{- '' -}} 186 {{- '' -}}
185 <div class="bandwidthChart vertical" title="Bandwidth: {{info.bandwi dth|bytes}}" style="height: {{(info.bandwidth / maxBandwidth * 100)|round(method ='ceil')|int}}px;"></div> 187 <div class="bandwidthChart vertical" title="Bandwidth: {{info.bandwi dth|bytes}}" style="height: {{(info.bandwidth / maxBandwidth * 100)|round(method ='ceil')|int}}px;"></div>
186 </td> 188 </td>
187 {%- if loop.last and info.id|int < 23 %} 189 {%- if loop.last and info.id|int < 23 %}
188 {%- for dummyHour in range(info.id|int + 1, 24) %} 190 {%- for dummyHour in range(info.id|int + 1, 24) %}
189 <td align="center" style="vertical-align: bottom;"> 191 <td align="center" style="vertical-align: bottom;">
190 <div class="hitsChart vertical" title="Hits: 0" style="height: 1 px;"></div> 192 <div class="hitsChart vertical" title="Hits: 0" style="height: 1 px;"></div>
(...skipping 21 matching lines...) Expand all
212 {%- endfor %} 214 {%- endfor %}
213 </tr> 215 </tr>
214 </table> 216 </table>
215 217
216 <table align="center"> 218 <table align="center">
217 <tr> 219 <tr>
218 <th bgcolor="#ECECEC">Hour</th> 220 <th bgcolor="#ECECEC">Hour</th>
219 <th bgcolor="#66DDEE" colspan="2">Hits</th> 221 <th bgcolor="#66DDEE" colspan="2">Hits</th>
220 <th bgcolor="#2EA495">Bandwidth</th> 222 <th bgcolor="#2EA495">Bandwidth</th>
221 </tr> 223 </tr>
222 {%- set totalHits = hour|sum(attribute='hits') %} 224 {%- set totalHits = hour|sum(attribute='hits')|ensuremin(1) %}
223 {%- set totalBandwidth = hour|sum(attribute='bandwidth') %} 225 {%- set totalBandwidth = hour|sum(attribute='bandwidth')|ensuremin(1) %}
224 {%- for info in hour %} 226 {%- for info in hour %}
225 <tr> 227 <tr>
226 <td>{{info.id}}</td> 228 <td>{{info.id}}</td>
227 <td align="right">{{info.hits}}</td> 229 <td align="right">{{info.hits}}</td>
228 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 230 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
229 <td align="right">{{info.bandwidth|bytes}}</td> 231 <td align="right">{{info.bandwidth|bytes}}</td>
230 </tr> 232 </tr>
231 {%- endfor %} 233 {%- endfor %}
232 </table> 234 </table>
233 </div> 235 </div>
234 236
235 {%- if app %} 237 {%- if app %}
236 <div class="block_title">Browsers</div> 238 <div class="block_title">Browsers</div>
237 <div class="block"> 239 <div class="block">
238 <table align="center"> 240 <table align="center">
239 <tr> 241 <tr>
240 <th bgcolor="#ECECEC">Browser</th> 242 <th bgcolor="#ECECEC">Browser</th>
241 <th bgcolor="#66DDEE" colspan="2">Hits</th> 243 <th bgcolor="#66DDEE" colspan="2">Hits</th>
242 <th bgcolor="#2EA495">Bandwidth</th> 244 <th bgcolor="#2EA495">Bandwidth</th>
243 </tr> 245 </tr>
244 {%- set maxHits, maxBandwidth = app|max(attribute='hits'),app|max(attrib ute='bandwidth') %} 246 {%- set maxHits = app|max(attribute='hits')|ensuremin(1) %}
245 {%- set totalHits = app|sum(attribute='hits') %} 247 {%- set maxBandwidth = app|max(attribute='bandwidth')|ensuremin(1) %}
246 {%- set totalBandwidth = app|sum(attribute='bandwidth') %} 248 {%- set totalHits = app|sum(attribute='hits')|ensuremin(1) %}
249 {%- set totalBandwidth = app|sum(attribute='bandwidth')|ensuremin(1) %}
247 {%- for info in app[0:10] %} 250 {%- for info in app[0:10] %}
248 <tr> 251 <tr>
249 <td>{{info.id}}</td> 252 <td>{{info.id}}</td>
250 <td align="right">{{info.hits}}</td> 253 <td align="right">{{info.hits}}</td>
251 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 254 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
252 <td align="right">{{info.bandwidth|bytes}}</td> 255 <td align="right">{{info.bandwidth|bytes}}</td>
253 <td class="chart"> 256 <td class="chart">
254 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br /> 257 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br />
255 <div class="bandwidthChart horizontal" style="width: {{(info.bandwid th / maxBandwidth * 100)|round(method='ceil')|int}}px;"></div> 258 <div class="bandwidthChart horizontal" style="width: {{(info.bandwid th / maxBandwidth * 100)|round(method='ceil')|int}}px;"></div>
256 </td> 259 </td>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 293
291 <div class="block_title">Countries</div> 294 <div class="block_title">Countries</div>
292 <div class="block"> 295 <div class="block">
293 <table align="center"> 296 <table align="center">
294 <tr> 297 <tr>
295 <th bgcolor="#ECECEC" colspan="3">Country</th> 298 <th bgcolor="#ECECEC" colspan="3">Country</th>
296 <th bgcolor="#66DDEE" colspan="2">Hits</th> 299 <th bgcolor="#66DDEE" colspan="2">Hits</th>
297 <th bgcolor="#2EA495">Bandwidth</th> 300 <th bgcolor="#2EA495">Bandwidth</th>
298 <th>&nbsp;</th> 301 <th>&nbsp;</th>
299 </tr> 302 </tr>
300 {%- set maxHits, maxBandwidth = country|max(attribute='hits'),country|ma x(attribute='bandwidth') %} 303 {%- set maxHits = country|max(attribute='hits')|ensuremin(1) %}
301 {%- set totalHits = country|sum(attribute='hits') %} 304 {%- set maxBandwidth = country|max(attribute='bandwidth')|ensuremin(1) % }
302 {%- set totalBandwidth = country|sum(attribute='bandwidth') %} 305 {%- set totalHits = country|sum(attribute='hits')|ensuremin(1) %}
306 {%- set totalBandwidth = country|sum(attribute='bandwidth')|ensuremin(1) %}
303 {%- for info in country[0:10] %} 307 {%- for info in country[0:10] %}
304 <tr> 308 <tr>
305 <td><div class="flag {{info.image}}"></div></td> 309 <td><div class="flag {{info.image}}"></div></td>
306 <td>{{info.name}}</td> 310 <td>{{info.name}}</td>
307 <td>{{info.id}}</td> 311 <td>{{info.id}}</td>
308 <td align="right">{{info.hits}}</td> 312 <td align="right">{{info.hits}}</td>
309 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 313 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
310 <td align="right">{{info.bandwidth|bytes}}</td> 314 <td align="right">{{info.bandwidth|bytes}}</td>
311 <td class="chart"> 315 <td class="chart">
312 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br /> 316 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br />
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 355
352 <div class="block_title">Download mirrors</div> 356 <div class="block_title">Download mirrors</div>
353 <div class="block"> 357 <div class="block">
354 <table align="center"> 358 <table align="center">
355 <tr> 359 <tr>
356 <th bgcolor="#ECECEC">Mirror</th> 360 <th bgcolor="#ECECEC">Mirror</th>
357 <th bgcolor="#66DDEE" colspan="2">Hits</th> 361 <th bgcolor="#66DDEE" colspan="2">Hits</th>
358 <th bgcolor="#2EA495">Bandwidth</th> 362 <th bgcolor="#2EA495">Bandwidth</th>
359 <th>&nbsp;</th> 363 <th>&nbsp;</th>
360 </tr> 364 </tr>
361 {%- set maxHits, maxBandwidth = mirror|max(attribute='hits'),mirror|max( attribute='bandwidth') %} 365 {%- set maxHits = mirror|max(attribute='hits')|ensuremin(1) %}
362 {%- set totalHits = mirror|sum(attribute='hits') %} 366 {%- set maxBandwidth = mirror|max(attribute='bandwidth')|ensuremin(1) %}
363 {%- set totalBandwidth = mirror|sum(attribute='bandwidth') %} 367 {%- set totalHits = mirror|sum(attribute='hits')|ensuremin(1) %}
368 {%- set totalBandwidth = mirror|sum(attribute='bandwidth')|ensuremin(1) %}
364 {%- for info in mirror %} 369 {%- for info in mirror %}
365 <tr> 370 <tr>
366 <td>{{info.id}}</td> 371 <td>{{info.id}}</td>
367 <td align="right">{{info.hits}}</td> 372 <td align="right">{{info.hits}}</td>
368 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 373 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
369 <td align="right">{{info.bandwidth|bytes}}</td> 374 <td align="right">{{info.bandwidth|bytes}}</td>
370 <td class="chart"> 375 <td class="chart">
371 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br /> 376 <div class="hitsChart horizontal" style="width: {{(info.hits / maxHi ts * 100)|round(method='ceil')|int}}px;"></div><br />
372 <div class="bandwidthChart horizontal" style="width: {{(info.bandwid th / maxBandwidth * 100)|round(method='ceil')|int}}px;"></div> 377 <div class="bandwidthChart horizontal" style="width: {{(info.bandwid th / maxBandwidth * 100)|round(method='ceil')|int}}px;"></div>
373 </td> 378 </td>
374 </tr> 379 </tr>
375 {%- endfor %} 380 {%- endfor %}
376 </table> 381 </table>
377 </div> 382 </div>
378 </body> 383 </body>
379 </html> 384 </html>
LEFTRIGHT

Powered by Google App Engine
This is Rietveld