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

Side by Side Diff: sitescripts/stats/template/fileStats.html

Issue 29934561: #1537 - Remove stats processing from sitescripts (Closed) Base URL: https://hg.adblockplus.org/sitescripts
Patch Set: Created Nov. 2, 2018, 12:42 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
OLDNEW
(Empty)
1 <!--
2 - This file is part of the Adblock Plus web scripts,
3 - Copyright (C) 2006-present eyeo GmbH
4 -
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
7 - published by the Free Software Foundation.
8 -
9 - Adblock Plus is distributed in the hope that it will be useful,
10 - but WITHOUT ANY WARRANTY; without even the implied warranty of
11 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 - GNU General Public License for more details.
13 -
14 - You should have received a copy of the GNU General Public License
15 - along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 -->
17
18 <!DOCTYPE html>
19 <html lang="en">
20 <head>
21 <meta name="robots" content="noindex,nofollow" />
22 <meta charset="utf-8">
23 <link rel="stylesheet" type="text/css" href="../../../static/stats.css" />
24 <link rel="stylesheet" type="text/css" href="../../../static/flags.css" />
25 <link rel="stylesheet" type="text/css" href="../../../static/hours.css" />
26 <title>Statistics for file {{fileName}} ({{month|monthname}})</title>
27 <script type="text/javascript">
28 document.addEventListener("click", function(event)
29 {
30 if (event.target.className == "showAllLink")
31 {
32 document.getElementById(event.target.getAttribute("data-hide")).style. display = "none";
33 document.getElementById(event.target.getAttribute("data-show")).style. display = "";
34 event.preventDefault();
35 }
36 }, false);
37 </script>
38 </head>
39
40 <body style="margin-top: 0px">
41 <a name="top">&nbsp;</a>
42 <table class="block" width="100%">
43 <tr>
44 <td class="title" width="250">Statistics for file:</td>
45 <td>{{url}}</td>
46 </tr>
47 <tr>
48 <td class="title" width="250">Last update:</td>
49 <td>{{now|formattime}}</td>
50 </tr>
51 <tr>
52 <td class="title" width="250">Reported period:</td>
53 <td>Month {{month|monthname}} (<a href="{{overview_url}}">To overview pa ge</a>)</td>
54 </tr>
55 {%- if filter %}
56 <tr>
57 <td class="title" width="250">Filter:</td>
58 <td>
59 {%- if filter.field.filter %}
60 {{filter.field.title}} only
61 {%- else %}
62 {{filter.field.coltitle}} is {{filter.value}}
63 {%- endif %}
64 (<a href="index.html">Remove filter</a>)</td>
65 </tr>
66 {%- endif %}
67 </table>
68
69 {%- macro row(name, value, params, special=False, emph=False, chart=True, fi ltered_url=None) %}
70 <tr{% if special %} class="special"{% endif%}>
71 <td{% if emph %} class="emph"{% endif%}>
72 {%- if filtered_url %}
73 <a href="{{filtered_url}}">
74 {%- endif %}
75
76 {%- if not special and params.field.name == "hour" -%}
77 <div class="hour hour{{name|int % 12 + 1}}"></div> {{name}}
78 {%- elif not special and params.field.name == "weekday" -%}
79 {{name|weekday}}
80 {%- elif not special and params.field.name == "country" -%}
81 <div class="flag {{name}}"></div> {{name|countryname}} <div class="c ountrycode">{{name}}</div>
82 {%- else -%}
83 {{name}}
84 {%- endif -%}
85
86 {%- if filtered_url %}
87 </a>
88 {%- endif %}
89 </td>
90 <td align="right">{{value.hits}}</td>
91 <td align="right">{{value.hits|percentage(params.totalhits)|round(precis ion=1)}}%</td>
92 <td align="right">{{value.bandwidth|bytes}}</td>
93 <td align="right">{{value.bandwidth|percentage(params.totalbandwidth)|ro und(precision=1)}}%</td>
94 {%- if chart %}
95 <td class="chart">
96 <div class="hitsChart" style="width: {{value.hits|percentage(params. maxhits)|round(method='ceil')|int}}px;"></div><br />
97 <div class="bandwidthChart" style="width: {{value.bandwidth|percenta ge(params.maxbandwidth)|round(method='ceil')|int}}px;"></div>
98 </td>
99 {%- else %}
100 <td>&nbsp;</td>
101 {%- endif %}
102 </tr>
103 {%- endmacro %}
104
105 {# Using selectattr filter would be nice but servers don't have Jinja 2.7 ye t #}
106 {%- set filterFields = [] %}
107 {%- for field in fields %}
108 {%- if field.filter and field.name in data and "True" in data[field.name] %}
109 {%- set dummy = filterFields.append(field) %}
110 {%- endif %}
111 {%- endfor %}
112
113 <div id="quickLinks">
114 {%- if filterFields|length > 0 %}
115 <a href="#overview">Overview</a>
116 {%- endif %}
117
118 {%- for field in fields %}
119 {%- if not field.filter and not field.hidden and field.name in data %}
120 <a href="#{{field.name}}">{{field.title}}</a>
121 {%- endif %}
122 {%- endfor %}
123 </div>
124
125 {%- if filterFields|length > 0 %}
126 {%- if filter %}
127 {%- set params = {"totalhits": data.hits, "totalbandwidth": data.bandwid th, "field": {"name": None}} %}
128 {%- else %}
129 {%- set items = data.day|sortfield("day") %}
130 {%- set params = {"totalhits": items|sumhits, "totalbandwidth": items|su mbandwidth, "field": {"name": None}} %}
131 {%- endif %}
132 <div id="overview" class="block_title">Overview</div>
133 <div class="block">
134 <table align="center">
135 <tr>
136 <th bgcolor="#ECECEC">Condition</th>
137 <th bgcolor="#66DDEE" colspan="2">Hits</th>
138 <th bgcolor="#2EA495" colspan="2">Bandwidth</th>
139 </tr>
140 {%- for field in filterFields %}
141 {{row(field.title, data[field.name].True, params, chart=False,
142 filtered_url=filtered_urls.get(field.name, {}).get("True", Non e))}}
143 {%- endfor %}
144 {{row("Total", {"hits": params.totalhits, "bandwidth": params.totalban dwidth}, params, special=True, emph=True, chart=False)}}
145 </table>
146 </div>
147 {%- endif %}
148
149 {%- for field in fields %}
150 {%- if not field.filter and not field.hidden and field.name in data %}
151 {%- set items = data[field.name]|sortfield(field) %}
152 {%- set params = {"maxhits": items|maxhits, "maxbandwidth": items|maxban dwidth,
153 "totalhits": items|sumhits, "totalbandwidth": items|su mbandwidth,
154 "field": field} %}
155 {%- set count = items|length %}
156 <div id="{{field.name}}" class="block_title">{{field.title}}</div>
157 <div class="block">
158 <table align="center">
159 <tr>
160 <th bgcolor="#ECECEC">{{field.coltitle}}</th>
161 <th bgcolor="#66DDEE" colspan="2">Hits</th>
162 <th bgcolor="#2EA495" colspan="2">Bandwidth</th>
163 </tr>
164 {%- for name, value in items[0:field|defaultcount] %}
165 {{row(name, value, params, special=name|isspecial(field),
166 filtered_url=filtered_urls.get(field.name, {}).get(name, None))} }
167 {%- endfor %}
168 {%- if count > field|defaultcount %}
169 <tr id="{{field.name}}_showAll" class="special">
170 <td>
171 Other
172 <a href="#" class="showAllLink" data-hide="{{field.name}}_showAl l" data-show="{{field.name}}_additionalItems">
173 Show all
174 </a>
175 </td>
176 <td align="right">{{items[field|defaultcount:]|sumhits}}</td>
177 <td>&nbsp;</td>
178 <td align="right">{{items[field|defaultcount:]|sumbandwidth|bytes} }</td>
179 <td>&nbsp;</td>
180 <td>&nbsp;</td>
181 </tr>
182 <tbody id="{{field.name}}_additionalItems" style="display: none;">
183 {%- for name, value in items[field|defaultcount:] %}
184 {{row(name, value, params, special=name|isspecial(field),
185 filtered_url=filtered_urls.get(field.name, {}).get(name, None) )}}
186 {%- endfor %}
187 </tbody>
188 {%- endif %}
189 {%- if field.showaverage %}
190 {%- set avghits = (params.totalhits / count)|int %}
191 {%- set avgbandwidth = (params.totalbandwidth / count)|int %}
192 {{row("Average", {"hits": avghits, "bandwidth": avgbandwidth}, par ams, special=True, emph=True)}}
193 {%- endif %}
194 {%- if field.name == "day" and filterFields|length == 0 %}
195 {{row("Total", {"hits": params.totalhits, "bandwidth": params.tota lbandwidth}, params, special=True, emph=True, chart=False)}}
196 {%- endif %}
197 </table>
198 </div>
199 {%- endif %}
200 {%- endfor %}
201 </body>
202 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld