Give every API value with a unit as a number (closes #199)
check / check (push) Waiting to run
check / check (push) Waiting to run
A value with a unit is now a number, and its field name ends in the unit, as the vendored API_POLICIES.md requires. @meta.execution_time becomes execution_time_ms. In the stats answers, uptime, connection_duration, memory_usage and whois_stats.current_interval become uptime_seconds, connection_duration_seconds, memory_usage_bytes and whois_stats.current_interval_seconds. connection_duration_seconds is null while the feed is not connected. The status page formats the numbers itself. REPO_POLICIES.md is re-vendored from the same sneak/prompts commit. Model: opus-5-5
This commit is contained in:
@@ -401,6 +401,8 @@
|
||||
const REFRESH_PERIOD_MS = 2000;
|
||||
const STALE_AFTER_REFRESHES = 3;
|
||||
const MS_PER_SECOND = 1000;
|
||||
const SECONDS_PER_MINUTE = 60;
|
||||
const SECONDS_PER_HOUR = 3600;
|
||||
const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
const SPINNER_COLOURS = ['#e74c3c', '#e67e22', '#f1c40f', '#27ae60', '#3498db', '#9b59b6'];
|
||||
|
||||
@@ -443,7 +445,18 @@
|
||||
function formatNumber(num) {
|
||||
return num.toLocaleString();
|
||||
}
|
||||
|
||||
|
||||
// formatDuration writes a number of seconds in hours, minutes and
|
||||
// seconds, such as "1h 18m 34s" or "18.2s", with at most one decimal.
|
||||
function formatDuration(totalSeconds) {
|
||||
const hours = Math.floor(totalSeconds / SECONDS_PER_HOUR);
|
||||
const minutes = Math.floor(totalSeconds % SECONDS_PER_HOUR / SECONDS_PER_MINUTE);
|
||||
const seconds = parseFloat((totalSeconds % SECONDS_PER_MINUTE).toFixed(1));
|
||||
if (hours > 0) return hours + 'h ' + minutes + 'm ' + seconds + 's';
|
||||
if (minutes > 0) return minutes + 'm ' + seconds + 's';
|
||||
return seconds + 's';
|
||||
}
|
||||
|
||||
function formatProcessingTime(ms) {
|
||||
if (ms < 0.001) {
|
||||
return (ms * 1000).toFixed(0) + ' µs';
|
||||
@@ -619,11 +632,13 @@
|
||||
noteMessageCount(data.total_messages);
|
||||
|
||||
// Update all metrics
|
||||
document.getElementById('uptime').textContent = data.uptime;
|
||||
document.getElementById('uptime').textContent = formatDuration(data.uptime_seconds);
|
||||
document.getElementById('go_version').textContent = data.go_version;
|
||||
document.getElementById('goroutines').textContent = formatNumber(data.goroutines);
|
||||
document.getElementById('memory_usage').textContent = data.memory_usage;
|
||||
document.getElementById('connection_duration').textContent = data.connection_duration;
|
||||
document.getElementById('memory_usage').textContent = formatBytes(data.memory_usage_bytes);
|
||||
// connection_duration_seconds is null while the stream is not connected.
|
||||
document.getElementById('connection_duration').textContent =
|
||||
data.connection_duration_seconds === null ? 'disconnected' : formatDuration(data.connection_duration_seconds);
|
||||
document.getElementById('reconnect_count').textContent = formatNumber(data.reconnect_count);
|
||||
document.getElementById('total_messages').textContent = formatNumber(data.total_messages);
|
||||
document.getElementById('messages_per_sec').textContent = formatNumber(Math.round(data.messages_per_sec));
|
||||
@@ -672,7 +687,7 @@
|
||||
const errorsEl = document.getElementById('whois_errors');
|
||||
errorsEl.textContent = formatNumber(data.whois_stats.errors_last_hour);
|
||||
errorsEl.className = 'metric-value' + (data.whois_stats.errors_last_hour > 0 ? ' disconnected' : '');
|
||||
document.getElementById('whois_interval').textContent = data.whois_stats.current_interval;
|
||||
document.getElementById('whois_interval').textContent = formatDuration(data.whois_stats.current_interval_seconds);
|
||||
}
|
||||
|
||||
// Update handler stats
|
||||
|
||||
Reference in New Issue
Block a user