[object Object]

← back to Rentv

fix(news-dedup): newsSig amount normalization strips commas + scales a no-unit raw-dollar amount to millions — '$985,000' was captured as '985' and signed as $985M, risking a false same-deal merge (hiding a distinct story). Mil/Bil/k cases unchanged

14e137d5d10cabc854035ec08d4281170bb2158f · 2026-08-06 10:24:33 -0700 · Steve

Files touched

Diff

commit 14e137d5d10cabc854035ec08d4281170bb2158f
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Aug 6 10:24:33 2026 -0700

    fix(news-dedup): newsSig amount normalization strips commas + scales a no-unit raw-dollar amount to millions — '$985,000' was captured as '985' and signed as $985M, risking a false same-deal merge (hiding a distinct story). Mil/Bil/k cases unchanged
---
 server.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/server.js b/server.js
index 341561eb..b615ebd7 100644
--- a/server.js
+++ b/server.js
@@ -1230,12 +1230,15 @@ const NEWS_STOP = new Set(('the a an of for to in on at and or with from into bu
   + 'avenue street road boulevard drive court place plaza tower towers sales').split(/\s+/).filter(Boolean));
 function newsSig(title) {
   const t = String(title || '').toLowerCase();
-  const money = t.match(/\$\s?([\d.]+)\s?(billion|bil|b|million|mil|m|k)?/);
+  const money = t.match(/\$\s?([\d,.]+)\s?(billion|bil|b|million|mil|m|k)?/);
   let m = '';
   // Normalize EVERY amount to the same base unit = MILLIONS: billion ×1000, million ×1, k(thousand) ÷1000.
   // So $100k→0.1, $100M→100, $100B→100000 — all on one scale. Do NOT "fix" `u==='k'` to *=1000: that
   // would equate $100k with $100B and break news dedup. (kept 1 decimal so $47.5M ≠ $48.2M.)
-  if (money && money[1]) { let n = parseFloat(money[1]); const u = money[2] || ''; if (/^b/.test(u)) n *= 1000; if (u === 'k') n /= 1000; if (!isNaN(n)) m = (Math.round(n * 10) / 10).toString(); }
+  // Base unit = MILLIONS. A comma'd raw-dollar amount ("$985,000") has NO unit word, so strip the commas
+  // and, when the number is large (>=1000, i.e. real dollars not millions-shorthand), scale it down to
+  // millions — else "$985,000" would sign as $985M and could false-merge with a genuine $985M deal.
+  if (money && money[1]) { let n = parseFloat(money[1].replace(/,/g, '')); const u = money[2] || ''; if (/^b/.test(u)) n *= 1000; else if (u === 'k') n /= 1000; else if (!u && n >= 1000) n /= 1e6; if (!isNaN(n)) m = (Math.round(n * 10) / 10).toString(); }
   const units = ((t.match(/([\d,]{2,})\s?-?\s?unit/) || [])[1] || '').replace(/,/g, '');
   // distinctive tokens = property names, cities, unusual terms (brokers/generics already removed)
   const toks = new Set(t.replace(/[^a-z0-9 ]/g, ' ').split(/\s+/).filter(w => w.length >= 4 && !NEWS_STOP.has(w)));

← f4d659e3 auto-data-snapshot: 2026-08-06T10:21:57 (6 data files) — dat  ·  back to Rentv  ·  PR CRM: user-authored notes on any entity (org/broker/person 6b792cc9 →