← back to Commercialrealestate
condos: normalize junk broker/firm placeholders (N/A etc) to null (yoloforever c8)
a241df1f2e0b512bb1e2270e6346738ef3ecc9d7 · 2026-08-01 20:36:13 -0700 · Steve
A condo carried firm_name='N/A' (a scrape placeholder stored as a real value) —
it rendered as a clickable 'N/A' firm drill-link (→ dead ?firm=N%2FA) and showed
as a distinct 'N/A' firm in filters. New cleanAttr() helper nulls the exact
placeholder class (N/A|Unknown|None|TBD|-) in /api/condos broker/firm (both DB +
snapshot). Anchored regex so real names ('None Inc') pass through. Future-proofs
against new placeholders. Verified live (throwaway): 0 N/A rows served.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit a241df1f2e0b512bb1e2270e6346738ef3ecc9d7
Author: Steve <steve@designerwallcoverings.com>
Date: Sat Aug 1 20:36:13 2026 -0700
condos: normalize junk broker/firm placeholders (N/A etc) to null (yoloforever c8)
A condo carried firm_name='N/A' (a scrape placeholder stored as a real value) —
it rendered as a clickable 'N/A' firm drill-link (→ dead ?firm=N%2FA) and showed
as a distinct 'N/A' firm in filters. New cleanAttr() helper nulls the exact
placeholder class (N/A|Unknown|None|TBD|-) in /api/condos broker/firm (both DB +
snapshot). Anchored regex so real names ('None Inc') pass through. Future-proofs
against new placeholders. Verified live (throwaway): 0 N/A rows served.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
scripts/serve.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/serve.js b/scripts/serve.js
index effdd79..715ee3c 100644
--- a/scripts/serve.js
+++ b/scripts/serve.js
@@ -608,6 +608,13 @@ function fhaEffectiveSignal(c, today) {
return (exp < today) ? 'fha_expired' : 'fha_approved';
}
+// Normalize scrape placeholder strings ("N/A", "Unknown", "None", "TBD", "-") in an attribution
+// field to null, so a placeholder never renders as a real broker/firm (a clickable "N/A" drill-link)
+// or counts as a distinct firm in filters. Real values pass through untouched.
+function cleanAttr(v) {
+ return (v && /^(n\/?a|unknown|none|tbd|-+)$/i.test(String(v).trim())) ? null : v;
+}
+
// Listing-level sibling: a scraped condo's warrantable_status is frozen at scrape-time. The matched
// FHA cert's expiration rides inside warrant_source ("...Approved, exp MM/DD/YYYY"), so re-derive at
// request time — a listing whose cert has since lapsed must read fha_expired, not fha_approved.
@@ -670,7 +677,7 @@ app.get('/api/condos', async (req, res) => {
FROM condo_card ${where} ORDER BY (status='active') DESC, created_at DESC LIMIT 5000`, args);
if (r.rows.length) {
const today = new Date(); today.setHours(0, 0, 0, 0);
- let rows = r.rows.map(c => ({ ...c, warrantable_status: listingEffectiveWarrant(c, today) }));
+ let rows = r.rows.map(c => ({ ...c, warrantable_status: listingEffectiveWarrant(c, today), broker_name: cleanAttr(c.broker_name), firm_name: cleanAttr(c.firm_name) }));
if (status && status !== 'all') rows = rows.filter(c => c.warrantable_status === status);
return res.json({ condos: rows, label: CONDO_LABEL, source: 'db' });
}
@@ -681,7 +688,7 @@ app.get('/api/condos', async (req, res) => {
const file = path.join(ROOT, 'data', 'condos-redfin.json');
const { condos = [] } = JSON.parse(fs.readFileSync(file, 'utf8'));
const today = new Date(); today.setHours(0, 0, 0, 0);
- let rows = condos.map(c => ({ ...c, warrantable_status: listingEffectiveWarrant(c, today) }));
+ let rows = condos.map(c => ({ ...c, warrantable_status: listingEffectiveWarrant(c, today), broker_name: cleanAttr(c.broker_name), firm_name: cleanAttr(c.firm_name) }));
if (status && status !== 'all') rows = rows.filter(c => c.warrantable_status === status);
return res.json({ condos: rows, label: CONDO_LABEL, source: 'snapshot' });
} catch (e) {
← 9cea404 commercialrealestate: adopt href-to-deeper-data primitives (
·
back to Commercialrealestate
·
crcp: Matthews firm-direct recon — no listings JSON XHR (SSR a04788c →