Skip to content

Commit a02ffb8

Browse files
mpstatonclaude
andcommitted
feat(crm-starter-export): bare-surname rows match their unique person — "Haslam" finds Bill Haslam
Unique-surname fallback in the person-match pass: fires only when the entire row name is a single token (≥5 chars) and exactly one person carries that surname. Landed with tonight's identifications: Patrick J. McGovern Foundation (operator-confirmed, mcgovern.org), Bill Haslam person-anchored as Former Governor on the operator's office-of-the-governor-tennessee org, Pyramid Peak Foundation (websiteless funder — grant-data profile links operator-supplied, web_presence observation records the shape). Mandelblatt joins Bob Campbell as deliberately parked. Files changed: - scripts/export-crm-orgs-csv.mjs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RW28dw3kQAKXr2ZNefCukE
1 parent d9b1dd1 commit a02ffb8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/export-crm-orgs-csv.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,14 @@ const persons = (await db.query(
162162
{ client: args.client },
163163
))?.[0] ?? [];
164164
const personByNorm = new Map();
165+
const personsBySurname = new Map(); // surname → persons[] (unique-only rule below)
165166
for (const p of persons) {
166167
for (const cand of [p.name, p.full_name]) {
167168
const n = normName(cand);
168169
if (n && !personByNorm.has(n)) personByNorm.set(n, p);
169170
}
171+
const surname = normName((p.name ?? p.full_name ?? '').split(' ').slice(-1)[0]);
172+
if (surname) personsBySurname.set(surname, [...(personsBySurname.get(surname) ?? []), p]);
170173
}
171174
const personMatch = (name) => {
172175
const direct = personByNorm.get(normName(name));
@@ -187,6 +190,12 @@ const personMatch = (name) => {
187190
const p = personByNorm.get(toks.slice(0, toks.length - drop).join(' '));
188191
if (p) return p;
189192
}
193+
// Bare-surname row ("Haslam") → the person, ONLY when the whole row name
194+
// is one token, ≥5 chars, and exactly one person carries that surname.
195+
if (toks.length === 1 && toks[0].length >= 5) {
196+
const bySurname = personsBySurname.get(toks[0]) ?? [];
197+
if (bySurname.length === 1) return bySurname[0];
198+
}
190199
return null;
191200
};
192201

0 commit comments

Comments
 (0)