Line tree: gold outline follows the chain's BuyerCounted events, plus a legend

The Overview tree painted gold on the first N chips (N = buyer count) instead of
the members the contract actually counted, so a non-buyer listed first showed as
qualified (Hugh's line, 2026-09-12). /api/my/line now flags each member with
qualified from BuyerCounted events for the account's ids; the tree uses that flag
and shows a legend for gold / plain / open chips.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-12 07:42:24 -05:00
parent e46780f872
commit abc76c47c8
3 changed files with 6 additions and 2 deletions
+3
View File
@@ -1234,10 +1234,12 @@ const server = http.createServer(async (req, res) => {
const own = (await accounts.positions(s.email)).filter(p => p.memberId);
const myIds = new Set([myId, ...own.map(p => p.memberId)].filter(Boolean));
const earnedBy = {};
const qualified = new Set(); // members the contract counted as this account's qualifying buyers ($20+)
if (myIds.size) {
for (const ev of chain.recentEvents(1e9)) {
if (ev.type === 'TierPaid' && myIds.has(ev.recipientId) && ev.buyerId)
earnedBy[ev.buyerId] = (BigInt(earnedBy[ev.buyerId] || '0') + BigInt(ev.amountWei)).toString();
if (ev.type === 'BuyerCounted' && myIds.has(ev.sponsorId) && ev.newBuyerId) qualified.add(ev.newBuyerId);
}
}
const out = levels.map(L => ({ level: L.level, members: L.members.map(m => ({
@@ -1245,6 +1247,7 @@ const server = http.createServer(async (req, res) => {
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
email: L.level === 1 ? m.email : null, // directs only
joined: m.created,
qualified: !!(m.memberId && qualified.has(m.memberId)),
earnedWei: (m.memberId && earnedBy[m.memberId]) || '0' })) }));
// the member's own linked positions sit on level 1 too, labelled as theirs
if (own.length) {