[object Object]

← back to build-pages

p/:slug: per-project 7-day sparkline in meta line

59b1208c558bd6c0397be8e7c062a381b4ae950d · 2026-05-13 19:17:39 -0700 · SteveStudio2

Files touched

Diff

commit 59b1208c558bd6c0397be8e7c062a381b4ae950d
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Wed May 13 19:17:39 2026 -0700

    p/:slug: per-project 7-day sparkline in meta line
---
 server.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index f967b50..cb1955c 100644
--- a/server.js
+++ b/server.js
@@ -551,12 +551,20 @@ app.get('/p/:slug', async (req, res, next) => {
       <p class="bp-meta">repo: <code>${esc(p.repo.replace(HOME, '~'))}</code> · ${commits.length} commits · ${(() => {
         const now = Date.now(), dayMs = 86400000;
         let d24 = 0, d7 = 0;
+        const buckets = new Array(7).fill(0);
         for (const c of commits) {
           const age = now - new Date(c.dateISO).getTime();
           if (age < dayMs) d24++;
           if (age < 7 * dayMs) d7++;
+          if (age < 7 * dayMs && age >= 0) {
+            const idx = 6 - Math.floor(age / dayMs);
+            if (idx >= 0 && idx < 7) buckets[idx]++;
+          }
         }
-        return `<strong>${d24}</strong> in last 24h, <strong>${d7}</strong> in last 7d`;
+        const blocks = ['▁','▂','▃','▄','▅','▆','▇','█'];
+        const max = Math.max(...buckets, 1);
+        const spark = buckets.map(n => n === 0 ? ' ' : blocks[Math.min(7, Math.floor((n / max) * 7))]).join('');
+        return `<strong>${d24}</strong> in last 24h, <strong>${d7}</strong> in last 7d · <code class="bp-spark" title="${buckets.join(' / ')}">${spark}</code>`;
       })()}</p>
 
       <section class="bp-section">

← b6fe68d home: 7-day velocity sparkline (Unicode block-chars, scales  ·  back to build-pages  ·  refactor: extract sparkline(commits, days) helper — DRY acro fdee564 →