-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.html
220 lines (197 loc) · 8.33 KB
/
stats.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html><html>
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stats for xen-calc</title>
<!-- Generated from realfavicongenerator.net: -->
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="256x256" href="favicon-256x256.png">
<link rel="icon" type="image/png" sizes="128x128" href="favicon-128x128.png">
<link rel="icon" type="image/png" sizes="64x64" href="favicon-64x64.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="style.css" />
<!-- Includes: -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="stats.js"></script>
<script type="text/javascript">
// Returns yesterday's date in the AoE time zone in YYYY-MM-DD format
function getAOEISODate(daysOffset) {
const offset = -12 - 24 * (daysOffset || 0); // -12 for AoE, -24 for yesterday
const unix = new Date().getTime() + offset * 3600 * 1000;
return new Date(unix).toISOString().split("T")[0];
}
function percentParens(a, b) {
if (!isFinite(total) || total <= 0) { return ""; };
return " (" + (+(100*a/b).toFixed(1)) + "%)";
}
function onLoad(res) {
const [total, newLoads] = [res["total"] || 0, res["new load"] || 0];
const [intervals, notes, edos] = [res["t interval"] || 0, res["t note"] || 0, res["t EDO"] || 0];
let [qs, rs, rs_tot] = [[], [], 0];
for (const s in res) {
if (s[1] == " ") {
if (s[0] == "q") {
let unabbr_s = s.slice(4);
for (const [s1,s2] of logQueryStrMap) {
if (unabbr_s == s2) { unabbr_s = s1; break; }
}
let vb_str = "";
if (unabbr_s.substr(-10) == " (verbose)") {
unabbr_s = unabbr_s.slice(0, unabbr_s.length-10);
vb_str = " (verbose)";
}
if (queryFlipWordOrder.includes(unabbr_s)) {
unabbr_s = (s[2] == "i" ? "interval" : s[2] == "n" ? "note" : "EDO") + " " + unabbr_s;
}
else if (!queryTypeUnambigType.includes(unabbr_s)) {
unabbr_s = unabbr_s + " " + (s[2] == "i" ? "interval" : s[2] == "n" ? "note" : "EDO");
}
qs.push([unabbr_s + vb_str, res[s] || 0]);
}
if (s[0] == "r") {
let unabbr_s = s.slice(2);
for (const [s1,s2] of logResStrMap) {
if (unabbr_s == s2) { unabbr_s = s1; break; }
}
rs.push([unabbr_s, res[s] || 0]);
rs_tot += res[s] || 0;
}
}
}
qs.sort((a,b) => b[1] - a[1]);
rs.sort((a,b) => b[1] - a[1]);
if (rs_tot < total) { rs.push(["other", total - rs_tot]); }
$('#total').text(total);
$('#newLoads').text(newLoads);
$('#intervals').text(intervals + percentParens(intervals, total));
$('#notes').text(notes + percentParens(notes, total));
$('#edos').text(edos + percentParens(edos, total));
const qdat = google.visualization.arrayToDataTable([["Query type", "#"]].concat(qs));
const rdat = google.visualization.arrayToDataTable([["Result type", "#"]].concat(rs));
const qpie = new google.visualization.PieChart(document.getElementById('qpie'));
const rpie = new google.visualization.PieChart(document.getElementById('rpie'));
const opts = { chartArea: { left: 90, right: 50 },
backgroundColor: { fill: 'transparent' },
sliceVisibilityThreshold: 0 };
qpie.draw(qdat, Object.assign({}, opts, {title: "Queries by type"}));
rpie.draw(rdat, Object.assign({}, opts, {title: "Queries by result type"}));
}
function update(date) {
const minUnix = new Date("2021-08-29").getTime();
const maxUnix = new Date(getAOEISODate(1)).getTime();
if (date) {
$('#date').text(date);
$('#numDays').empty();
$('#seeAll').text("see all days").attr("href", "?d=all");
}
else {
$('#date').text("2021-08-29 to " + getAOEISODate(1));
const numDays = 1 + (maxUnix - minUnix) / (24 * 3600 * 1000);
$('#numDays').text(numDays + " days total");
$('#seeAll').text("see specific day").attr("href", "?d=" + getAOEISODate(1));
}
$('#nextDate').removeClass("hidden");
$('#nextDate').removeClass("invisible");
$('#prevDate').removeClass("hidden");
$('#prevDate').removeClass("invisible");
if (!date) {
$('#nextDate').addClass("hidden");
$('#prevDate').addClass("hidden");
}
else {
if (new Date(date).getTime() >= maxUnix) {
$('#nextDate').addClass("invisible");
}
if (new Date(date).getTime() <= minUnix) {
$('#prevDate').addClass("invisible");
}
}
logQuery(date, undefined, onLoad);
}
function updateURL(date) {
const url = new URL(window.location);
url.searchParams.set("d", date ? date : "all");
history.pushState({}, date, url);
}
window.onpopstate = setStateFromURL;
function setStateFromURL() {
const urlParams = new URLSearchParams(window.location.search);
const dParam = urlParams.has("d") ? urlParams.get("d") : "all";
let date = undefined;
if (dParam !== "all") {
date = getAOEISODate(1);
const dInts = dParam.split("-").map(x => parseInt(x));
if (dInts.length == 1 && isFinite(dInts[0]) && dInts[0] >= 0) {
date = getAOEISODate(dInts[0]);
}
else if (dInts.length == 3 && dInts.every(x => isFinite(x))) {
date = `${("0000" + dInts[0]).substr(-4)}-`;
date += `${("00" + dInts[1]).substr(-2)}-`
date += `${("00" + dInts[2]).substr(-2)}`;
}
}
update(date);
}
$(document).ready(function() {
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(() => setStateFromURL());
$('#prevDate').click(function () {
const maxUnix = new Date(getAOEISODate(1)).getTime();
const unix = Math.min(maxUnix, new Date($('#date').text()).getTime() - 24 * 3600 * 1000);
const date = new Date(unix).toISOString().split("T")[0];
update(date);
updateURL(date);
});
$('#nextDate').click(function () {
const minUnix = new Date("2021-08-29").getTime();
const unix = Math.max(minUnix, new Date($('#date').text()).getTime() + 24 * 3600 * 1000);
const date = new Date(unix).toISOString().split("T")[0];
update(date);
updateURL(date);
});
});
</script>
</head>
<body><div class="body-wrap">
<h1><a href=".">xen-calc</a></h1>
<div class="content" style="margin-top: 30px">
<h2>Stats</h2>
<p>
This page shows all the stats collected by xen-calc before today
<a class="alt" href="https://en.wikipedia.org/wiki/Anywhere_on_Earth">anywhere on earth</a>,
with the exception of the classes of errors raised and any "referrer" values. See the
<a class="alt" href="./about.html#privacy">privacy section of the about page</a>
for more detail.
</p>
<h4 style="text-align: center; margin-bottom: 5px">
<a id="prevDate" style="margin-right:15px" href="javascript:void(0)"><</a>
<span id="date">...</span> <a class="alt" href="https://en.wikipedia.org/wiki/Anywhere_on_Earth">AoE</a>
<a id="nextDate" style="margin-left:15px" href="javascript:void(0)">></a>
</h4>
<p id="numDaysP" style="text-align: center; margin-bottom: 5px">
<span id="numDays"></span> (<a id="seeAll" class="alt"></a>)
</p>
<p style="text-align: center; margin-bottom: -10px">
<span id="total">...</span> total queries made,
<span id="newLoads">...</span> new page loads
</p>
<div id="qpie" style="width: 100%; height: 400px"></div>
<p style="text-align: center; margin-top: -10px; margin-bottom: -10px">
<span id="intervals">...</span> interval queries,
<span id="notes">...</span> note queries,
<span id="edos">...</span> EDO queries
</p>
<div id="rpie" style="width: 100%; height: 400px"></div>
<br>
<p style="text-align: center">
<a href="." class=grey>Back to xen-calc</a> ·
<a href="./about.html" class=grey>About xen-calc</a> ·
<a href="https://www.yacavone.net" class=grey>My website</a>
</p>
</div>
</div></body>
</html>