Skip to content

Commit db81f6b

Browse files
mmckyclaude
andauthored
Overview: freshness badge — orange past a week, red past two (#24)
The front page now carries a last-updated badge under the header. The generated date is baked into the page, but the AGE is computed in the viewer's browser at view time — a baked-in color would itself go stale. Within 7 days it reads green ("up to date — last updated N days ago"); past 7 days it turns orange ("the weekly rebuild is overdue"); past 14, red ("the scheduled rebuild has stopped"). With the weekly cron in place, orange/red are an ops signal that CI has quietly failed, which is exactly the dashboard's failure mode to guard against. Icon + words on every state, never color alone. Part of #20. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent e19a410 commit db81f6b

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

scripts/render_audit.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@
207207
.meter .seg.b { background: var(--meter-b); }
208208
.meter.mini { height: 8px; max-width: 340px; margin: 6px 0 2px; border-radius: 4px; }
209209
tr.row-migrated td { background: var(--ok-bg); }
210+
.freshness {
211+
display: inline-block; border-radius: 6px; padding: 4px 12px; margin-top: 12px;
212+
font-size: 13px; font-weight: 600;
213+
background: var(--ok-bg); color: var(--ok); border: 1px solid var(--line);
214+
}
215+
.freshness.warn { background: var(--warn-bg); color: var(--warn); }
216+
.freshness.crit { background: var(--crit-bg); color: var(--crit); }
210217
/* bar list — one measure, single hue, labeled rows */
211218
.barlist { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 12px; align-items: center; margin: 14px 0; }
212219
.barlist .lbl { font-size: 13px; }
@@ -460,6 +467,27 @@ def render_index(audit: dict) -> str:
460467
<a href="{DL}/blob/main/scripts/build_audit.py">a script</a> — not maintained by hand.
461468
Companion to the migration of lecture data into
462469
<a href="{DL}">QuantEcon/data-lectures</a>.</p>
470+
<span id="freshness" class="freshness" data-generated="{esc(audit["generated"])}"
471+
title="Rebuilt on every change to data-lectures and weekly on schedule — a badge older than a week means the scheduled rebuild has stopped.">
472+
● generated {esc(audit["generated"])}</span>
473+
<script>
474+
(function () {{
475+
var el = document.getElementById('freshness');
476+
var gen = new Date(el.dataset.generated + 'T00:00:00Z');
477+
var days = Math.floor((Date.now() - gen.getTime()) / 86400000);
478+
if (isNaN(days)) return;
479+
var age = days <= 0 ? 'today' : days === 1 ? 'yesterday' : days + ' days ago';
480+
if (days > 14) {{
481+
el.classList.add('crit');
482+
el.textContent = '✗ stale — last updated ' + age + ' (' + el.dataset.generated + '); the scheduled rebuild has stopped';
483+
}} else if (days > 7) {{
484+
el.classList.add('warn');
485+
el.textContent = '⚠ last updated ' + age + ' (' + el.dataset.generated + ') — the weekly rebuild is overdue';
486+
}} else {{
487+
el.textContent = '● up to date — last updated ' + age + ' (' + el.dataset.generated + ')';
488+
}}
489+
}})();
490+
</script>
463491
</header>
464492
{tiles}
465493
{migration_meter(audit)}

0 commit comments

Comments
 (0)