[object Object]

← back to Commercialrealestate

CRCP: California-scope the broker DB — /api/brokers/all defaults to CA + unknown (hides 22 confirmed out-of-state; ?scope=all override). Backed by DRE cross-ref: 2,075/2,537 now confirmed CA

de954cf6d9aa0e93b79d413e81890d03346ad930 · 2026-07-11 09:21:32 -0700 · Steve Abrams

Files touched

Diff

commit de954cf6d9aa0e93b79d413e81890d03346ad930
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sat Jul 11 09:21:32 2026 -0700

    CRCP: California-scope the broker DB — /api/brokers/all defaults to CA + unknown (hides 22 confirmed out-of-state; ?scope=all override). Backed by DRE cross-ref: 2,075/2,537 now confirmed CA
---
 package-lock.json |  4 ++--
 package.json      |  2 +-
 scripts/serve.js  | 10 +++++++++-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 0f14ecc..a60c0fd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "commercialrealestate",
-  "version": "0.6.1",
+  "version": "0.7.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "commercialrealestate",
-      "version": "0.6.1",
+      "version": "0.7.0",
       "dependencies": {
         "better-sqlite3": "^12.11.1",
         "express": "^4.22.2",
diff --git a/package.json b/package.json
index 4280764..e4f8694 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "commercialrealestate",
-  "version": "0.6.1",
+  "version": "0.7.0",
   "private": true,
   "description": "LA County CRE investment explorer — multi-firm sourced, Census + assessor enriched, Qwen-analyzed",
   "scripts": {
diff --git a/scripts/serve.js b/scripts/serve.js
index 75bdc48..925a9f4 100644
--- a/scripts/serve.js
+++ b/scripts/serve.js
@@ -179,16 +179,24 @@ app.get('/api/brokers/linkedin', async (req, res) => {
 // ALL brokers/agents with EVERY field — backs the sortable/searchable broker grid+list (broker-grid.html).
 app.get('/api/brokers/all', async (req, res) => {
   if (!brokerdb) return res.json({ brokers: [], unavailable: true });
+  // This is an LA commercial-RE database, but the Crexi feed pulled in out-of-state brokers.
+  // Default view is California-scoped: state='CA' (confirmed by office address OR a CA-DRE
+  // name match) PLUS still-unknown (no address AND no DRE match — likely CA, not proven).
+  // Confirmed out-of-state brokers (state present and != 'CA') are excluded unless ?scope=all.
+  const scope = String(req.query.scope || 'ca');
+  const caFilter = scope === 'all' ? '' : `WHERE (b.state = 'CA' OR b.state IS NULL)`;
   try {
     const rows = (await brokerdb.pool.query(
       `SELECT b.id, b.name, f.name firm, b.agent_type, b.phone, b.email, b.website, b.linkedin,
               b.license, b.title, b.total_assets, b.specialties, b.office_addr, b.crexi_id, b.source, b.created_at,
+              b.state, b.dre_match, b.dre_license,
               (SELECT count(*) FROM broker_listing bl WHERE bl.broker_id=b.id)
               + (SELECT count(*) FROM broker_condo bc WHERE bc.broker_id=b.id) AS listings,
               ${ARCSTONE_FLAG_SQL} AS arcstone_flag
          FROM broker b LEFT JOIN firm f ON f.id=b.firm_id
+         ${caFilter}
          ORDER BY listings DESC NULLS LAST, b.name`)).rows;
-    res.json({ brokers: rows, total: rows.length });
+    res.json({ brokers: rows, total: rows.length, scope, note: scope === 'all' ? 'all states' : 'California-scoped (CA + unknown; 22 confirmed out-of-state hidden — use ?scope=all to see them)' });
   } catch (e) { res.status(502).json({ error: String(e.message).split('\n')[0], brokers: [] }); }
 });
 

← 482a169 CRCP: confirm unknown-geography brokers as CA via CA-DRE cro  ·  back to Commercialrealestate  ·  auto-save: 2026-07-11T12:13:17 (1 files) — data/condos-redfi f898564 →