← back to Commercialrealestate
CRCP crexi DB scraper: count brokers actually INSERTED on --apply (summary said 0 while 4 landed) (TK-12033)
46f772139bb2cd6f17e82cb3617756f352fd6ce7 · 2026-09-23 12:16:46 -0700 · Steve Abrams
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7HcZ26MePoJ5QpcvDhKmH
Files touched
M scripts/scrape-crexi-loopnet.js
Diff
commit 46f772139bb2cd6f17e82cb3617756f352fd6ce7
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Sep 23 12:16:46 2026 -0700
CRCP crexi DB scraper: count brokers actually INSERTED on --apply (summary said 0 while 4 landed) (TK-12033)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7HcZ26MePoJ5QpcvDhKmH
---
scripts/scrape-crexi-loopnet.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/scrape-crexi-loopnet.js b/scripts/scrape-crexi-loopnet.js
index c15502c..a5e7703 100644
--- a/scripts/scrape-crexi-loopnet.js
+++ b/scripts/scrape-crexi-loopnet.js
@@ -225,7 +225,7 @@ async function resolveBroker(agent, firm, license, phone) {
`INSERT INTO broker (name, firm_id, phone, license, source, agent_type, created_at)
VALUES ($1,$2,$3,$4,'crexi','commercial',now()) RETURNING id`,
[agent, firmId, phone || null, license || null]).catch(e => { console.log(' (broker insert err:', String(e.message).split('\n')[0], ')'); return { rows: [] }; })).rows[0];
- return ins ? { brokerId: ins.id, role: 'agent' } : { role: 'firm-listing' };
+ return ins ? { brokerId: ins.id, role: 'agent', created: true } : { role: 'firm-listing' };
}
(async () => {
@@ -282,12 +282,12 @@ async function resolveBroker(agent, firm, license, phone) {
if (seenAddrs.has(nAddr(address))) { continue; } // detail address already ingested (cross-run dedup)
if (!price) { unpriced++; console.log(` · [skip] ${address} — no plausible headline price`); continue; }
if (!agent) { console.log(` · [skip] ${address} — no listing agent on detail page`); continue; }
- const { brokerId, role } = await resolveBroker(agent, firm, det.license, det.phone);
+ const { brokerId, role, created: madeNew } = await resolveBroker(agent, firm, det.license, det.phone);
if (!role || (role === 'firm-listing' && !firm)) { console.log(` · [skip] ${address} — ${agent} unresolvable (no firm)`); continue; }
- const tag = role === 'firm-listing' ? '[firm-level]' : brokerId === 'NEW' ? '[would create]' : brokerId ? '' : '[no broker]';
+ const tag = role === 'firm-listing' ? '[firm-level]' : brokerId === 'NEW' ? '[would create]' : madeNew ? '[created]' : brokerId ? '' : '[no broker]';
console.log(` ✓ $${price.toLocaleString()} ${address} — ${agent} @ ${firm || '?'} ${tag}`);
if (role === 'firm-listing') firmLevel++;
- else if (brokerId === 'NEW') created++;
+ else if (brokerId === 'NEW' || madeNew) created++; // count REAL inserts too — the apply-path summary said 0 while 4 rows landed (TK-12033)
else if (brokerId) matched++;
if (APPLY && (role === 'firm-listing' ? firm : (brokerId && brokerId !== 'NEW'))) {
const bid = role === 'firm-listing' ? null : brokerId;
← e778fe0 CRCP crexi DB scraper: also strip a leading 'NNN SqFt' marke
·
back to Commercialrealestate
·
CRCP crexi DB scraper: harden per Kimi review — scalar resul cd84313 →