My line: show who sponsored each person on every row, all three levels

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-14 10:15:44 -05:00
parent f2c155a6d2
commit e699513636
5 changed files with 11 additions and 3 deletions
+6
View File
@@ -1656,8 +1656,14 @@ const server = http.createServer(async (req, res) => {
if (ev.type === 'BuyerCounted' && myIds.has(ev.sponsorId) && ev.newBuyerId) qualified.add(ev.newBuyerId);
}
}
// who sponsored each person (Marty, 2026-09-14): resolve sponsorRef tokens (username, share code or member id) against the line itself
const meAcct = await accounts.byEmail(s.email); const byTok = {};
const label = a => a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : 'member');
for (const a of [meAcct, ...levels.flatMap(L => L.members)].filter(Boolean)) { const n = label(a); if (a.username) byTok[String(a.username).toLowerCase()] = n; if (a.code) byTok[String(a.code).toLowerCase()] = n; if (a.memberId) byTok[String(a.memberId)] = n; }
const sponsorOf = m => { const t = String(m.sponsorRef || '').toLowerCase(); if (!t) return null; if (meAcct && (t === String(meAcct.username || '').toLowerCase() || t === String(meAcct.code || '').toLowerCase() || t === String(meAcct.memberId || ''))) return 'you'; return byTok[t] || ('@' + t); };
const out = levels.map(L => ({ level: L.level, members: L.members.map(m => ({
memberId: m.memberId || 0,
sponsor: sponsorOf(m),
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
ref: m.code || null, // opens the activity drop-down (Clinton's ask, 2026-09-14): any of the three levels
email: L.level === 1 ? m.email : null, // directs only