[object Object]

← back to build-pages

home: today vs yesterday side-by-side counts (Steve's PT calendar days) + 1 smoke

ca0922f402749740b3a979ea72be1ec7f578af7f · 2026-05-13 20:40:57 -0700 · SteveStudio2

Files touched

Diff

commit ca0922f402749740b3a979ea72be1ec7f578af7f
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Wed May 13 20:40:57 2026 -0700

    home: today vs yesterday side-by-side counts (Steve's PT calendar days) + 1 smoke
---
 server.js     | 23 ++++++++++++++---------
 test/smoke.js |  3 ++-
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/server.js b/server.js
index 861a39e..ce6d424 100644
--- a/server.js
+++ b/server.js
@@ -354,18 +354,23 @@ app.get('/', async (req, res, next) => {
     // Velocity counters + 7-day sparkline across the whole fleet. Concats
     // per-project commit lists so the helper sees every commit in one shot.
     const fleetCommits = entries.flatMap(e => _projectCache.get(e.slug)?.commits || []);
-    // Today-in-PT count — Steve's calendar day, not rolling-24h.
-    const todayPT = (() => {
-      const todayStr = todayInTz('America/Los_Angeles');
-      const startMs = startOfDayInTz(todayStr, 'America/Los_Angeles');
-      const endMs = startMs + 86400000;
+    // Today-in-PT + yesterday-PT counts — Steve's calendar days, not rolling-24h.
+    // Lets Steve see "237 today, 47 yesterday" at a glance.
+    const ptDay = (offsetDays) => {
+      const tz = 'America/Los_Angeles';
+      const baseStr = todayInTz(tz);
+      const dayStartMs = startOfDayInTz(baseStr, tz) + offsetDays * 86400000;
+      const endMs = dayStartMs + 86400000;
+      const dateStr = new Date(dayStartMs + 43200000).toLocaleString('sv-SE', { timeZone: tz }).slice(0, 10);
       let n = 0;
       for (const c of fleetCommits) {
         const t = new Date(c.dateISO).getTime();
-        if (t >= startMs && t < endMs) n++;
+        if (t >= dayStartMs && t < endMs) n++;
       }
-      return { date: todayStr, count: n };
-    })();
+      return { date: dateStr, count: n };
+    };
+    const todayPT     = ptDay(0);
+    const yesterdayPT = ptDay(-1);
     const fleetSpark = sparkline(fleetCommits);
     const sparkChars = fleetSpark.spark;
     const dayBuckets = fleetSpark.buckets;
@@ -415,7 +420,7 @@ app.get('/', async (req, res, next) => {
       <h1>build journals</h1>
       <p class="bp-lede">Every build, every commit, every line. Click into a project to see how it actually got made.</p>
       <p class="bp-meta">${entries.length} projects · ${totalCommits} commits · ${totalIdeas} design-rationale ideas surfaced</p>
-      <p class="bp-meta">today (PT ${todayPT.date}): <strong>${todayPT.count}</strong> commits · velocity: <strong>${last24}</strong> in last 24h · <strong>${last7d}</strong> in last 7d · 7-day shape <code class="bp-spark" title="${dayBuckets.join(' / ')}">${sparkChars}</code> · ${(() => {
+      <p class="bp-meta">today (PT): <strong>${todayPT.count}</strong> · yesterday: <strong>${yesterdayPT.count}</strong> · last 24h: <strong>${last24}</strong> · last 7d: <strong>${last7d}</strong> · 7-day shape <code class="bp-spark" title="${dayBuckets.join(' / ')}">${sparkChars}</code> · ${(() => {
         const [l1] = require('os').loadavg();
         const cls = l1 < 8 ? 'bp-load-ok' : l1 < 20 ? 'bp-load-warn' : 'bp-load-hot';
         return `host load <span class="bp-load ${cls}">${l1.toFixed(1)}</span> (1m)`;
diff --git a/test/smoke.js b/test/smoke.js
index f88d1c2..2725297 100644
--- a/test/smoke.js
+++ b/test/smoke.js
@@ -100,7 +100,8 @@ function check(name, cond, hint = '') {
   check('home: load badge',        /class="bp-load (bp-load-ok|bp-load-warn|bp-load-hot)"/.test(r.body));
   check('home: 7-day sparkline',   /class="bp-spark"/.test(r.body));
   check('home: deepest rationale rail', /Deepest rationale/.test(r.body));
-  check('home: today PT counter', /today \(PT \d{4}-\d{2}-\d{2}\): <strong>\d+<\/strong>/.test(r.body));
+  check('home: today PT counter', /today \(PT\): <strong>\d+<\/strong>/.test(r.body));
+  check('home: yesterday counter', /yesterday: <strong>\d+<\/strong>/.test(r.body));
   check('home: canonical',         /rel="canonical"/.test(r.body));
   check('home: og:title',          /property="og:title"/.test(r.body));
   check('home: WebSite JSON-LD',   /"@type":"WebSite"/.test(r.body));

← b57cacd refactor: extract startOfDayInTz + todayInTz helpers — DRY t  ·  back to build-pages  ·  smoke: track 'last 24h' line instead of removed 'velocity:' 7aefa06 →