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

Side by Side Diff: sitescripts/logs/template/subscription.html

Issue 9503001: Subscription stats: Make sure there can be no division by zero errors (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « .hgsubstate ('k') | sitescripts/logs/template/subscriptionOverview.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 <tr> 41 <tr>
42 <td class="title" width="250">Reported period:</td> 42 <td class="title" width="250">Reported period:</td>
43 <td>Month {{month|monthname}} (<a href="{{overviewURL}}">To overview pag e</a>)</td> 43 <td>Month {{month|monthname}} (<a href="{{overviewURL}}">To overview pag e</a>)</td>
44 </tr> 44 </tr>
45 </table> 45 </table>
46 46
47 <div class="block_title">Days of month</div> 47 <div class="block_title">Days of month</div>
48 <div class="block"> 48 <div class="block">
49 <table align="center" style="margin-bottom: 20px;"> 49 <table align="center" style="margin-bottom: 20px;">
50 <tr align="bottom"> 50 <tr align="bottom">
51 {%- set maxHits, maxBandwidth = day|max(attribute='hits'), day|max(att ribute='bandwidth') %} 51 {%- set maxHits = day|max(attribute='hits')|ensuremin(1) %}
52 {%- set totalHits = day|sum(attribute='hits') %} 52 {%- set maxBandwidth = day|max(attribute='bandwidth')|ensuremin(1) %}
53 {%- set totalBandwidth = day|sum(attribute='bandwidth') %} 53 {%- set totalHits = day|sum(attribute='hits')|ensuremin(1) %}
54 {%- set totalBandwidth = day|sum(attribute='bandwidth')|ensuremin(1) % }
54 {%- set dayCount = day|length %} 55 {%- set dayCount = day|length %}
55 {%- if currentMonth and dayCount > 1 %} 56 {%- if currentMonth and dayCount > 1 %}
56 {%- set totalHits = totalHits - day[-1].hits %} 57 {%- set totalHits = totalHits - day[-1].hits %}
57 {%- set totalBandwidth = totalBandwidth - day[-1].bandwidth %} 58 {%- set totalBandwidth = totalBandwidth - day[-1].bandwidth %}
58 {%- set dayCount = dayCount - 1 %} 59 {%- set dayCount = dayCount - 1 %}
59 {%- endif %} 60 {%- endif %}
60 {%- for info in day %} 61 {%- for info in day %}
61 <td align="center" style="vertical-align: bottom;"> 62 <td align="center" style="vertical-align: bottom;">
62 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px;"></div> 63 <div class="hitsChart vertical" title="Hits: {{info.hits}}" style="h eight: {{(info.hits / maxHits * 100)|round(method='ceil')|int}}px;"></div>
63 {{- '' -}} 64 {{- '' -}}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 <td align="right">&nbsp;</td> 129 <td align="right">&nbsp;</td>
129 <td align="right">{{totalBandwidth|bytes}}</td> 130 <td align="right">{{totalBandwidth|bytes}}</td>
130 </tr> 131 </tr>
131 </table> 132 </table>
132 </div> 133 </div>
133 134
134 <div class="block_title">Days of week</div> 135 <div class="block_title">Days of week</div>
135 <div class="block"> 136 <div class="block">
136 <table align="center" style="margin-bottom: 20px;"> 137 <table align="center" style="margin-bottom: 20px;">
137 <tr align="bottom"> 138 <tr align="bottom">
138 {%- 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) %}
139 {%- for info in weekday %} 141 {%- for info in weekday %}
140 <td align="center" style="vertical-align: bottom;"> 142 <td align="center" style="vertical-align: bottom;">
141 <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>
142 {{- '' -}} 144 {{- '' -}}
143 <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>
144 </td> 146 </td>
145 {%- endfor %} 147 {%- endfor %}
146 </tr> 148 </tr>
147 <tr> 149 <tr>
148 {%- for info in weekday %} 150 {%- for info in weekday %}
149 <td align="center"{% if info.id > 4 %} class="special"{% endif %}> 151 <td align="center"{% if info.id > 4 %} class="special"{% endif %}>
150 {{info.id|weekday}} 152 {{info.id|weekday}}
151 </td> 153 </td>
152 {%- endfor %} 154 {%- endfor %}
153 </tr> 155 </tr>
154 </table> 156 </table>
155 157
156 <table align="center"> 158 <table align="center">
157 <tr> 159 <tr>
158 <th bgcolor="#ECECEC">Day</th> 160 <th bgcolor="#ECECEC">Day</th>
159 <th bgcolor="#66DDEE" colspan="2">Hits</th> 161 <th bgcolor="#66DDEE" colspan="2">Hits</th>
160 <th bgcolor="#2EA495">Bandwidth</th> 162 <th bgcolor="#2EA495">Bandwidth</th>
161 </tr> 163 </tr>
162 {%- set totalHits = weekday|sum(attribute='hits') %} 164 {%- set totalHits = weekday|sum(attribute='hits')|ensuremin(1) %}
163 {%- set totalBandwidth = weekday|sum(attribute='bandwidth') %} 165 {%- set totalBandwidth = weekday|sum(attribute='bandwidth')|ensuremin(1) %}
164 {%- for info in weekday %} 166 {%- for info in weekday %}
165 <tr{% if info.id > 4 %} class="special"{% endif %}> 167 <tr{% if info.id > 4 %} class="special"{% endif %}>
166 <td>{{info.id|weekday}}</td> 168 <td>{{info.id|weekday}}</td>
167 <td align="right">{{info.hits}}</td> 169 <td align="right">{{info.hits}}</td>
168 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 170 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
169 <td align="right">{{info.bandwidth|bytes}}</td> 171 <td align="right">{{info.bandwidth|bytes}}</td>
170 </tr> 172 </tr>
171 {%- endfor %} 173 {%- endfor %}
172 </table> 174 </table>
173 </div> 175 </div>
174 176
175 <div class="block_title">Hours</div> 177 <div class="block_title">Hours</div>
176 <div class="block"> 178 <div class="block">
177 <table align="center" style="margin-bottom: 20px;"> 179 <table align="center" style="margin-bottom: 20px;">
178 <tr align="bottom"> 180 <tr align="bottom">
179 {%- 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) %}
180 {%- for info in hour %} 183 {%- for info in hour %}
181 <td align="center" style="vertical-align: bottom;"> 184 <td align="center" style="vertical-align: bottom;">
182 <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>
183 {{- '' -}} 186 {{- '' -}}
184 <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>
185 </td> 188 </td>
186 {%- if loop.last and info.id|int < 23 %} 189 {%- if loop.last and info.id|int < 23 %}
187 {%- for dummyHour in range(info.id|int + 1, 24) %} 190 {%- for dummyHour in range(info.id|int + 1, 24) %}
188 <td align="center" style="vertical-align: bottom;"> 191 <td align="center" style="vertical-align: bottom;">
189 <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
211 {%- endfor %} 214 {%- endfor %}
212 </tr> 215 </tr>
213 </table> 216 </table>
214 217
215 <table align="center"> 218 <table align="center">
216 <tr> 219 <tr>
217 <th bgcolor="#ECECEC">Hour</th> 220 <th bgcolor="#ECECEC">Hour</th>
218 <th bgcolor="#66DDEE" colspan="2">Hits</th> 221 <th bgcolor="#66DDEE" colspan="2">Hits</th>
219 <th bgcolor="#2EA495">Bandwidth</th> 222 <th bgcolor="#2EA495">Bandwidth</th>
220 </tr> 223 </tr>
221 {%- set totalHits = hour|sum(attribute='hits') %} 224 {%- set totalHits = hour|sum(attribute='hits')|ensuremin(1) %}
222 {%- set totalBandwidth = hour|sum(attribute='bandwidth') %} 225 {%- set totalBandwidth = hour|sum(attribute='bandwidth')|ensuremin(1) %}
223 {%- for info in hour %} 226 {%- for info in hour %}
224 <tr> 227 <tr>
225 <td>{{info.id}}</td> 228 <td>{{info.id}}</td>
226 <td align="right">{{info.hits}}</td> 229 <td align="right">{{info.hits}}</td>
227 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 230 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
228 <td align="right">{{info.bandwidth|bytes}}</td> 231 <td align="right">{{info.bandwidth|bytes}}</td>
229 </tr> 232 </tr>
230 {%- endfor %} 233 {%- endfor %}
231 </table> 234 </table>
232 </div> 235 </div>
233 236
234 {%- if app %} 237 {%- if app %}
235 <div class="block_title">Browsers</div> 238 <div class="block_title">Browsers</div>
236 <div class="block"> 239 <div class="block">
237 <table align="center"> 240 <table align="center">
238 <tr> 241 <tr>
239 <th bgcolor="#ECECEC">Browser</th> 242 <th bgcolor="#ECECEC">Browser</th>
240 <th bgcolor="#66DDEE" colspan="2">Hits</th> 243 <th bgcolor="#66DDEE" colspan="2">Hits</th>
241 <th bgcolor="#2EA495">Bandwidth</th> 244 <th bgcolor="#2EA495">Bandwidth</th>
242 </tr> 245 </tr>
243 {%- set maxHits, maxBandwidth = app|max(attribute='hits'),app|max(attrib ute='bandwidth') %} 246 {%- set maxHits = app|max(attribute='hits')|ensuremin(1) %}
244 {%- set totalHits = app|sum(attribute='hits') %} 247 {%- set maxBandwidth = app|max(attribute='bandwidth')|ensuremin(1) %}
245 {%- set totalBandwidth = app|sum(attribute='bandwidth') %} 248 {%- set totalHits = app|sum(attribute='hits')|ensuremin(1) %}
249 {%- set totalBandwidth = app|sum(attribute='bandwidth')|ensuremin(1) %}
246 {%- for info in app[0:10] %} 250 {%- for info in app[0:10] %}
247 <tr> 251 <tr>
248 <td>{{info.id}}</td> 252 <td>{{info.id}}</td>
249 <td align="right">{{info.hits}}</td> 253 <td align="right">{{info.hits}}</td>
250 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 254 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
251 <td align="right">{{info.bandwidth|bytes}}</td> 255 <td align="right">{{info.bandwidth|bytes}}</td>
252 <td class="chart"> 256 <td class="chart">
253 <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 />
254 <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>
255 </td> 259 </td>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 293
290 <div class="block_title">Countries</div> 294 <div class="block_title">Countries</div>
291 <div class="block"> 295 <div class="block">
292 <table align="center"> 296 <table align="center">
293 <tr> 297 <tr>
294 <th bgcolor="#ECECEC" colspan="3">Country</th> 298 <th bgcolor="#ECECEC" colspan="3">Country</th>
295 <th bgcolor="#66DDEE" colspan="2">Hits</th> 299 <th bgcolor="#66DDEE" colspan="2">Hits</th>
296 <th bgcolor="#2EA495">Bandwidth</th> 300 <th bgcolor="#2EA495">Bandwidth</th>
297 <th>&nbsp;</th> 301 <th>&nbsp;</th>
298 </tr> 302 </tr>
299 {%- set maxHits, maxBandwidth = country|max(attribute='hits'),country|ma x(attribute='bandwidth') %} 303 {%- set maxHits = country|max(attribute='hits')|ensuremin(1) %}
300 {%- set totalHits = country|sum(attribute='hits') %} 304 {%- set maxBandwidth = country|max(attribute='bandwidth')|ensuremin(1) % }
301 {%- set totalBandwidth = country|sum(attribute='bandwidth') %} 305 {%- set totalHits = country|sum(attribute='hits')|ensuremin(1) %}
306 {%- set totalBandwidth = country|sum(attribute='bandwidth')|ensuremin(1) %}
302 {%- for info in country[0:10] %} 307 {%- for info in country[0:10] %}
303 <tr> 308 <tr>
304 <td><div class="flag {{info.image}}"></div></td> 309 <td><div class="flag {{info.image}}"></div></td>
305 <td>{{info.name}}</td> 310 <td>{{info.name}}</td>
306 <td>{{info.id}}</td> 311 <td>{{info.id}}</td>
307 <td align="right">{{info.hits}}</td> 312 <td align="right">{{info.hits}}</td>
308 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 313 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
309 <td align="right">{{info.bandwidth|bytes}}</td> 314 <td align="right">{{info.bandwidth|bytes}}</td>
310 <td class="chart"> 315 <td class="chart">
311 <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
350 355
351 <div class="block_title">Download mirrors</div> 356 <div class="block_title">Download mirrors</div>
352 <div class="block"> 357 <div class="block">
353 <table align="center"> 358 <table align="center">
354 <tr> 359 <tr>
355 <th bgcolor="#ECECEC">Mirror</th> 360 <th bgcolor="#ECECEC">Mirror</th>
356 <th bgcolor="#66DDEE" colspan="2">Hits</th> 361 <th bgcolor="#66DDEE" colspan="2">Hits</th>
357 <th bgcolor="#2EA495">Bandwidth</th> 362 <th bgcolor="#2EA495">Bandwidth</th>
358 <th>&nbsp;</th> 363 <th>&nbsp;</th>
359 </tr> 364 </tr>
360 {%- set maxHits, maxBandwidth = mirror|max(attribute='hits'),mirror|max( attribute='bandwidth') %} 365 {%- set maxHits = mirror|max(attribute='hits')|ensuremin(1) %}
361 {%- set totalHits = mirror|sum(attribute='hits') %} 366 {%- set maxBandwidth = mirror|max(attribute='bandwidth')|ensuremin(1) %}
362 {%- set totalBandwidth = mirror|sum(attribute='bandwidth') %} 367 {%- set totalHits = mirror|sum(attribute='hits')|ensuremin(1) %}
368 {%- set totalBandwidth = mirror|sum(attribute='bandwidth')|ensuremin(1) %}
363 {%- for info in mirror %} 369 {%- for info in mirror %}
364 <tr> 370 <tr>
365 <td>{{info.id}}</td> 371 <td>{{info.id}}</td>
366 <td align="right">{{info.hits}}</td> 372 <td align="right">{{info.hits}}</td>
367 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td> 373 <td align="right">{{(info.hits / totalHits * 100)|round(precision=1)}} %</td>
368 <td align="right">{{info.bandwidth|bytes}}</td> 374 <td align="right">{{info.bandwidth|bytes}}</td>
369 <td class="chart"> 375 <td class="chart">
370 <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 />
371 <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>
372 </td> 378 </td>
373 </tr> 379 </tr>
374 {%- endfor %} 380 {%- endfor %}
375 </table> 381 </table>
376 </div> 382 </div>
377 </body> 383 </body>
378 </html> 384 </html>
OLDNEW
« no previous file with comments | « .hgsubstate ('k') | sitescripts/logs/template/subscriptionOverview.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld