Render "queue busy" badge on sources skipped due to pending_work
Replaces the confusing em-dash + raw `pending_work` text when no successful sweep has run yet.
This commit is contained in:
parent
ef9cacf981
commit
d900651b92
1 changed files with 26 additions and 8 deletions
|
|
@ -338,6 +338,11 @@
|
||||||
$("stat-breakdown").innerHTML = parts.join("<br>");
|
$("stat-breakdown").innerHTML = parts.join("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SKIP_REASON_LABELS = {
|
||||||
|
pending_work: "queue busy",
|
||||||
|
circuit_open: "breaker open",
|
||||||
|
};
|
||||||
|
|
||||||
function renderSources(sources) {
|
function renderSources(sources) {
|
||||||
$("sources-count").textContent = "(" + sources.length + ")";
|
$("sources-count").textContent = "(" + sources.length + ")";
|
||||||
if (!sources.length) {
|
if (!sources.length) {
|
||||||
|
|
@ -351,17 +356,30 @@
|
||||||
if (s.circuit_breaker_open) {
|
if (s.circuit_breaker_open) {
|
||||||
circuitBadge = '<span class="badge bad">OPEN</span>';
|
circuitBadge = '<span class="badge bad">OPEN</span>';
|
||||||
}
|
}
|
||||||
let skipBadge = "";
|
// Combine last_polled with skip_reason in one cell. Three cases:
|
||||||
if (s.last_skip_reason) {
|
// (a) polled OK → "5m ago"
|
||||||
skipBadge =
|
// (b) polled + skipped → "5m ago [queue busy]" (sweep ran then
|
||||||
' <span class="badge warn" title="Most recent sweep attempt was skipped.">' +
|
// backpressure kicked in)
|
||||||
escapeHtml(s.last_skip_reason) +
|
// (c) never polled but → "[queue busy]" alone — em-dash would
|
||||||
"</span>";
|
// skipped read as broken; the badge tells the
|
||||||
}
|
// real story (restart with work still
|
||||||
|
// in queue).
|
||||||
|
const reason = s.last_skip_reason;
|
||||||
|
const label = reason
|
||||||
|
? SKIP_REASON_LABELS[reason] || reason
|
||||||
|
: null;
|
||||||
|
const skipBadge = reason
|
||||||
|
? ` <span class="badge warn" title="Most recent sweep attempt was skipped (${escapeHtml(reason)}).">${escapeHtml(label)}</span>`
|
||||||
|
: "";
|
||||||
|
const polledCell = s.last_polled_at
|
||||||
|
? relTime(s.last_polled_at) + skipBadge
|
||||||
|
: reason
|
||||||
|
? skipBadge.trim()
|
||||||
|
: "—";
|
||||||
return `<tr>
|
return `<tr>
|
||||||
<td>${escapeHtml(s.source_id)}</td>
|
<td>${escapeHtml(s.source_id)}</td>
|
||||||
<td>${escapeHtml(s.type)}</td>
|
<td>${escapeHtml(s.type)}</td>
|
||||||
<td>${relTime(s.last_polled_at)}${skipBadge}</td>
|
<td>${polledCell}</td>
|
||||||
<td>${circuitBadge}</td>
|
<td>${circuitBadge}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<button onclick="refreshSource('${escapeHtml(s.source_id)}')">Refresh</button>
|
<button onclick="refreshSource('${escapeHtml(s.source_id)}')">Refresh</button>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue