[object Object]

← back to Allnewsdaily

feed balance: cap 3 items per outlet per column so no single source dominates (env PER_OUTLET)

996668c82082adab694a6b3c52a546ea6f3409bc · 2026-09-09 11:35:38 -0700 · Steve Abrams

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177CKXFpA1rVH3Sk24fgRZ9

Files touched

Diff

commit 996668c82082adab694a6b3c52a546ea6f3409bc
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 9 11:35:38 2026 -0700

    feed balance: cap 3 items per outlet per column so no single source dominates (env PER_OUTLET)
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_0177CKXFpA1rVH3Sk24fgRZ9
---
 lib/aggregate.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/aggregate.js b/lib/aggregate.js
index c37afcb..978ffac 100644
--- a/lib/aggregate.js
+++ b/lib/aggregate.js
@@ -7,6 +7,7 @@ const { rewriteAll } = require('./paraphrase');
 const FEEDS_PATH = path.join(__dirname, '..', 'data', 'feeds.json');
 const PER_FEED = parseInt(process.env.PER_FEED || '5', 10);          // items kept per feed
 const PER_COLUMN = parseInt(process.env.PER_COLUMN || '22', 10);      // items shown per column
+const PER_OUTLET = parseInt(process.env.PER_OUTLET || '3', 10);       // max items per outlet per column (diversity)
 
 function loadFeeds() {
   return JSON.parse(fs.readFileSync(FEEDS_PATH, 'utf8'));
@@ -39,6 +40,12 @@ async function buildColumn(colKey, col) {
     }
   }
   items.sort((a, b) => parseDate(b.date) - parseDate(a.date));
+  // Cap items per outlet so one source can't dominate a column (e.g. all-Apple on event day).
+  const perOutlet = {};
+  items = items.filter((it) => {
+    perOutlet[it.outlet] = (perOutlet[it.outlet] || 0) + 1;
+    return perOutlet[it.outlet] <= PER_OUTLET;
+  });
   items = items.slice(0, PER_COLUMN);
   const okCount = results.filter((a) => a.length > 0).length;
   return { key: colKey, title: col.title, items, ok: okCount, total: col.feeds.length };

← f1da61c wire-push: robust node resolution for launchd; add wire-push  ·  back to Allnewsdaily  ·  Front page: 2-min live-refresh loop + countdown counter + bi 0337f69 →