Line at a glance + My line: every level shows who made their $20+ buy and how many qualifying buyers of their own they have (Clinton); 60s member cache for line views
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,12 @@ const catalogCache = { at: 0, products: null };
|
||||
const wallUnlockedFor = bc => (bc >= 5 ? 3 : bc >= 2 ? 2 : 1);
|
||||
// every on-chain member id this session controls: the main wallet plus linked
|
||||
// positions (Qualified Start). Credits pool across them on the dashboard.
|
||||
const memberInfoCache = new Map(); // id -> { t, v } (60s): line views ask for every member's on-chain row
|
||||
async function cachedMember(id) {
|
||||
const c = memberInfoCache.get(id); if (c && Date.now() - c.t < 60000) return c.v;
|
||||
let v = null; try { v = await chain.member(id); } catch (e) {}
|
||||
memberInfoCache.set(id, { t: Date.now(), v }); return v;
|
||||
}
|
||||
async function myMemberIds(s) {
|
||||
const main = await auth.refreshMemberId(s);
|
||||
const ids = main ? [main] : [];
|
||||
@@ -1686,7 +1692,12 @@ const server = http.createServer(async (req, res) => {
|
||||
// a member's linked positions are theirs too: a qualifying buy from one of them lights their chip
|
||||
const posIds = {}; for (const m of levels.flatMap(L => L.members)) { try { posIds[m.email] = (await accounts.positions(m.email)).map(p => p.memberId).filter(Boolean); } catch (e) { posIds[m.email] = []; } }
|
||||
const idsOf = m => [m.memberId, ...(posIds[m.email] || [])].filter(Boolean);
|
||||
// Clinton's ask (2026-09-14): on levels 2 and 3 show who has made their $20+ buy (counted for their own
|
||||
// sponsor) and how many qualifying buyers of their own they have, so a leader can see who is one short
|
||||
const onchain = {};
|
||||
for (const m of levels.flatMap(L => L.members)) { let bought = false, buyers = 0; for (const id of idsOf(m)) { const mm = await cachedMember(id); if (mm) { if (mm.countedAsBuyer) bought = true; buyers += mm.buyerCount || 0; } } onchain[m.email] = { bought, buyers }; }
|
||||
const out = levels.map(L => ({ level: L.level, members: L.members.map(m => ({
|
||||
bought: onchain[m.email].bought, buyers: onchain[m.email].buyers,
|
||||
memberId: m.memberId || 0,
|
||||
sponsor: sponsorOf(m),
|
||||
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
|
||||
|
||||
Reference in New Issue
Block a user