[object Object]

← back to La Socrata Ingester

yoloforever c7 FIX (Cody): honest digest — verified-only headline + district table

d115714db811a33c5b93a5fa5faabaeb26059abe · 2026-08-12 07:46:34 -0700 · steve

Cody c7 kill-shot: district table silently summed the flagged $375M into CD9's total
(#1) while the deals list flagged it — $700M headline was 2x inflated. Now: headline
splits verified ($278M) vs flagged/unverified ($422M); district table sorts by verified
value + marks outlier rows (CD11 Palisades now correctly #1; CD9's single-outlier row
demoted). Added stale-feed guard. Publishable.

Files touched

Diff

commit d115714db811a33c5b93a5fa5faabaeb26059abe
Author: steve <steve@designerwallcoverings.com>
Date:   Wed Aug 12 07:46:34 2026 -0700

    yoloforever c7 FIX (Cody): honest digest — verified-only headline + district table
    
    Cody c7 kill-shot: district table silently summed the flagged $375M into CD9's total
    (#1) while the deals list flagged it — $700M headline was 2x inflated. Now: headline
    splits verified ($278M) vs flagged/unverified ($422M); district table sorts by verified
    value + marks outlier rows (CD11 Palisades now correctly #1; CD9's single-outlier row
    demoted). Added stale-feed guard. Publishable.
---
 scripts/deals-digest.js | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/scripts/deals-digest.js b/scripts/deals-digest.js
index 99f0c78..cf8d389 100644
--- a/scripts/deals-digest.js
+++ b/scripts/deals-digest.js
@@ -23,14 +23,21 @@ function main() {
   const feed = JSON.parse(fs.readFileSync(feedPath, 'utf8'));
   const deals = feed.deals || [];
   const stamp = feed.generated;
-  const totalValue = deals.reduce((s, d) => s + (d.project_value || 0), 0);
   const flagged = deals.filter(d => d.valuation_outlier).length;
+  const verifiedValue = deals.filter(d => !d.valuation_outlier).reduce((s, d) => s + (d.project_value || 0), 0);
+  const outlierValue = deals.filter(d => d.valuation_outlier).reduce((s, d) => s + (d.project_value || 0), 0);
 
   const L = [];
   L.push(`# LA Development Deals — ${stamp}`);
   L.push('');
-  L.push(`**${deals.length}** notable building permits issued in the last ${feed.window_days} days (project value ≥ ${money(feed.min_value)}), ranked by lead score. Total tracked project value: **${money(totalValue)}**.`);
+  // Headline uses VERIFIED value only; flagged/unverified permits shown separately so a
+  // single self-reported outlier can't inflate the total (Cody c7).
+  const outlierNote = flagged ? ` (plus ${money(outlierValue)} across ${flagged} flagged / unverified permit${flagged > 1 ? 's' : ''})` : '';
+  L.push(`**${deals.length}** notable building permits issued in the last ${feed.window_days} days (project value ≥ ${money(feed.min_value)}), ranked by lead score. Verified tracked value: **${money(verifiedValue)}**${outlierNote}.`);
   L.push('');
+  // Staleness guard (Cody c7): flag if the underlying feed isn't from today.
+  const today = new Date().toISOString().slice(0, 10);
+  if (stamp !== today) L.push(`> ⚠ Feed data is from ${stamp} (not today, ${today}). Re-run \`node scripts/deals-feed.js\` for current data.\n`);
 
   // Top deals
   L.push('## Top deals');
@@ -54,15 +61,21 @@ function main() {
   const byCd = {};
   for (const d of deals) {
     const k = d.council_district || '—';
-    (byCd[k] ||= { member: d.council_member, count: 0, value: 0 });
-    byCd[k].count++; byCd[k].value += d.project_value || 0;
+    (byCd[k] ||= { member: d.council_member, count: 0, verified: 0, unverified: 0 });
+    byCd[k].count++;
+    if (d.valuation_outlier) byCd[k].unverified += d.project_value || 0;
+    else byCd[k].verified += d.project_value || 0;
   }
-  const cdSorted = Object.entries(byCd).sort((a, b) => b[1].value - a[1].value).slice(0, 8);
+  // Sort by VERIFIED value so a district can't rank #1 on a single flagged permit (Cody c7).
+  const cdSorted = Object.entries(byCd).sort((a, b) => b[1].verified - a[1].verified).slice(0, 8);
   L.push('## By council district');
   L.push('');
-  L.push('| District | Member | Deals | Tracked value |');
+  L.push('| District | Member | Deals | Verified value |');
   L.push('|---|---|---:|---:|');
-  for (const [cd, v] of cdSorted) L.push(`| CD ${cd} | ${v.member || '—'} | ${v.count} | ${money(v.value)} |`);
+  for (const [cd, v] of cdSorted) {
+    const unv = v.unverified ? ` (+${money(v.unverified)} unverified ⚠)` : '';
+    L.push(`| CD ${cd} | ${v.member || '—'}${v.unverified ? ' ⚠' : ''} | ${v.count} | ${money(v.verified)}${unv} |`);
+  }
   L.push('');
 
   // Notes

← 02d9b82 yoloforever c7: RE-news deals-digest markdown generator (scr  ·  back to La Socrata Ingester  ·  viewer: make filters+sort shareable in the URL (deep-link/bo 1d08e30 →