[object Object]

← back to Rentv

fix(dealdesk): coveredBy guards the matched SEGMENT length, not the full needle — a needle like 'SF, CA 94105' was matching on 2-char 'sf' (∈ tranSFers) and falsely marking deals already-covered, skipping good Deal Desk candidates

8c370f63b824f5123088467ecd9cbd419841b46a · 2026-08-06 09:53:04 -0700 · Steve

Files touched

Diff

commit 8c370f63b824f5123088467ecd9cbd419841b46a
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Aug 6 09:53:04 2026 -0700

    fix(dealdesk): coveredBy guards the matched SEGMENT length, not the full needle — a needle like 'SF, CA 94105' was matching on 2-char 'sf' (∈ tranSFers) and falsely marking deals already-covered, skipping good Deal Desk candidates
---
 server.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index dad4a748..34efed31 100644
--- a/server.js
+++ b/server.js
@@ -1140,7 +1140,10 @@ app.post('/api/dealdesk/find', adminOnly, async (req, res) => {
   const arch = readJSON('news-archive.json', []); const items = Array.isArray(arch) ? arch : (arch.items || []);
   const coveredBy = (deal) => {
     const needle = [deal.address, deal.buyer, deal.seller, deal.headline || deal.title].filter(Boolean).map((s) => String(s).toLowerCase());
-    return items.find((a) => { const t = String(a.title || '').toLowerCase(); return needle.some((n) => n.length > 8 && t.includes(n.split(',')[0].trim())); });
+    // Guard the length of the SEGMENT actually matched, not the whole needle — else a needle like
+    // "SF, CA 94105" (len 12) passes the >8 check but matches on the 2-char "sf", which substring-hits
+    // "tranSFers"/"satiSFied" and falsely marks a deal already-covered (skipping a good candidate).
+    return items.find((a) => { const t = String(a.title || '').toLowerCase(); return needle.some((n) => { const seg = n.split(',')[0].trim(); return seg.length > 8 && t.includes(seg); }); });
   };
   // ── Gemini path (opt-in, paid) — only when explicitly requested AND a key exists.
   if (b.engine === 'gemini' && GEMINI_KEY) {

← cb99f313 auto-save: 2026-08-06T09:51:16 (8 files) — data/deals-regist  ·  back to Rentv  ·  harden(dealdesk): Cody gate — coveredBy matches the needle s f47b2a57 →