Admin members: resolve sponsors against every account, not the page's 500

The Members page loads the newest 500 accounts and built its sponsor name
lookup from that same list. Once the site passed 500 accounts every sponsor who
joined before that window became unfindable, so the page labelled them "dead
link: <name>" with a tooltip saying the member would fall into the holding
tank. It was doing that to 144 of the 500 rows, including cryptoassets 76
times, and not one token on the whole site is genuinely unresolvable.

Sponsorship itself was never affected: assignment at purchase time looks each
token up directly rather than scanning a list.

accounts.identities() returns the identity columns for every account with no
limit, which stays cheap at any size, and the page uses that for the lookup
while still showing 500 rows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-23 11:25:38 -05:00
parent 5c08be1c30
commit 8656f7ce4d
2 changed files with 13 additions and 2 deletions
+3 -1
View File
@@ -2998,8 +2998,10 @@ const server = http.createServer(async (req, res) => {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const members = await accounts.listAll(500);
// resolve each sponsor token (username, share code or member #) to the sponsor's name
// the lookup covers EVERY account, not the page's slice: built from `members` it called every
// sponsor who joined before the newest 500 a dead link (144 of them, Marty 2026-09-23)
const byTok = {};
for (const m of members) for (const t of [m.username, m.code, m.memberId ? String(m.memberId) : null]) if (t) byTok[String(t).toLowerCase()] = m;
for (const m of await accounts.identities()) for (const t of [m.username, m.code, m.memberId ? String(m.memberId) : null]) if (t) byTok[String(t).toLowerCase()] = m;
for (const m of members) {
const t = String(m.sponsorRef || '').toLowerCase();
const sp = t ? byTok[t] : null;