perf: serve long-range studies from a decoded closed-day cache

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-23 09:13:02 -03:00
1 parent 4143bf599e
commit 4ca9c7bf0c
16 files changed
+846 -83

No files matched your search

+11 -3
View File
@@ -301,9 +301,17 @@
if (r.status >= 500) { showError(t('error.load')); throw mkErr('HTTP ' + r.status, r.status); }
if (!r.ok) throw mkErr('HTTP ' + r.status, r.status);
hideError();
return r.json();
return r.json().then(function (j) { if (j && j.truncated === true) noteTruncated(); return j; });
}, function (e) { showError(t('error.load')); throw e; });
}
// A study that hit a real limit (event count, byte budget or time) says so; shown at most once per 20 s.
var truncAt = 0;
function noteTruncated() {
var now = Date.now();
if (now - truncAt < 20000) return;
truncAt = now;
toast(t('study.truncated'), 9000);
}
function qs(extra) {
var o = Object.assign({ host: state.host }, rangeParams());
for (var k in extra) o[k] = extra[k];
@@ -982,12 +990,12 @@
});
}
var toastBox = null;
function toast(msg) {
function toast(msg, ms) {
if (!toastBox) toastBox = $('#toasts');
if (!toastBox) return;
var n = h('div', 'toast', String(msg));
toastBox.appendChild(n);
setTimeout(function () { if (n.parentNode) n.parentNode.removeChild(n); }, 2600);
setTimeout(function () { if (n.parentNode) n.parentNode.removeChild(n); }, ms || 2600);
}
// POST/DELETE with a JSON body (same-origin cookie session); resolves with the parsed answer or rejects with its status.