Tank, roster and downline: sortable/filterable lists with last seen, surf earnings and wallet/payout state; admin Members table loads 5000 accounts
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+92
-23
@@ -238,6 +238,51 @@
|
||||
const PAGE_SIZE = 25;
|
||||
// My line is the longest page on the dashboard: its lists page at 10 (Marty, 2026-09-26)
|
||||
const LINE_PER = 10;
|
||||
// Sortable + filterable member lists (Marty, 2026-09-29): the holding tank, "Your line" and the three-level
|
||||
// downline share one toolbar. Every row carries joined, last seen, surf earnings and wallet/payout state so a
|
||||
// sponsor can spot "joined days ago, signed in today, earning on their own, wallet linked but payouts off".
|
||||
const LIST_UI = {};
|
||||
const dayStart = () => { const d = new Date(); d.setHours(0, 0, 0, 0); return d.getTime(); };
|
||||
const activeToday = m => (m.lastSeen || 0) >= dayStart();
|
||||
const LIST_SORTS = [
|
||||
{ k: 'seen', label: 'Last seen', v: m => m.lastSeen || 0 },
|
||||
{ k: 'joined', label: 'Joined', v: m => m.joined || 0 },
|
||||
{ k: 'earned', label: 'Surf earnings', v: m => m.earned || 0 },
|
||||
{ k: 'balance', label: 'Earned balance', v: m => m.balance || 0 },
|
||||
{ k: 'name', label: 'Name', v: m => String(m.name || '').toLowerCase(), str: true },
|
||||
];
|
||||
const LIST_FILTERS = [
|
||||
{ k: 'today', label: 'Active today', t: m => activeToday(m) },
|
||||
{ k: 'earning', label: 'Earning', t: m => (m.earned || 0) > 0 },
|
||||
{ k: 'wallet', label: 'Wallet linked', t: m => !!m.wallet },
|
||||
{ k: 'nopay', label: 'Wallet, payouts off', t: m => !!m.wallet && !m.activated },
|
||||
{ k: 'payouts', label: 'Payouts on', t: m => !!m.activated },
|
||||
{ k: 'nowallet', label: 'No wallet', t: m => !m.wallet },
|
||||
];
|
||||
const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: 'seen', dir: -1, on: new Set() });
|
||||
function listApply(key, rows) {
|
||||
const st = listState(key); const s = LIST_SORTS.find(x => x.k === st.sort) || LIST_SORTS[0];
|
||||
const out = (rows || []).filter(m => m.own || [...st.on].every(k => { const f = LIST_FILTERS.find(x => x.k === k); return !f || f.t(m); }));
|
||||
out.sort((a, b) => { const x = s.v(a), y = s.v(b); return (s.str ? String(x).localeCompare(String(y)) : x - y) * st.dir; });
|
||||
return out;
|
||||
}
|
||||
function listBar(key, total, shown, rerender, opts) {
|
||||
const st = listState(key); const hide = (opts && opts.hide) || [];
|
||||
const bar = document.createElement('div'); bar.className = 'lst-bar';
|
||||
bar.innerHTML = '<label class="lst-sort">Sort <select aria-label="Sort by">' + LIST_SORTS.map(s => '<option value="' + s.k + '"' + (s.k === st.sort ? ' selected' : '') + '>' + s.label + '</option>').join('') + '</select></label>'
|
||||
+ '<button type="button" class="lst-dir" title="Flip the order">' + (st.dir < 0 ? '↓ high to low' : '↑ low to high') + '</button>'
|
||||
+ '<span class="lst-chips">' + LIST_FILTERS.filter(f => !hide.includes(f.k)).map(f => '<button type="button" class="lst-chip' + (st.on.has(f.k) ? ' on' : '') + '" data-f="' + f.k + '" aria-pressed="' + (st.on.has(f.k) ? 'true' : 'false') + '">' + f.label + '</button>').join('') + '</span>'
|
||||
+ '<span class="lst-n">' + (shown === total ? total + (total === 1 ? ' person' : ' people') : shown + ' of ' + total) + '</span>';
|
||||
bar.querySelector('select').addEventListener('change', e => { st.sort = e.target.value; st.dir = st.sort === 'name' ? 1 : -1; rerender(); });
|
||||
bar.querySelector('.lst-dir').addEventListener('click', () => { st.dir = -st.dir; rerender(); });
|
||||
bar.querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (st.on.has(k)) st.on.delete(k); else st.on.add(k); rerender(); }));
|
||||
return bar;
|
||||
}
|
||||
const seenAgo = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + 'h ago'; const days = Math.floor(d / 86400e3); return days === 1 ? 'yesterday' : days + ' days ago'; };
|
||||
const seenChip = m => m.lastSeen ? '<span class="lchip' + (activeToday(m) ? ' on' : (Date.now() - m.lastSeen > 3 * 86400e3 ? ' warn' : '')) + '" title="Last sign-in">' + (activeToday(m) ? 'active today' : 'seen ' + seenAgo(m.lastSeen)) + '</span>' : '<span class="lchip warn">never signed in</span>';
|
||||
const earnChip = m => '<span class="lchip' + (m.earned ? ' on' : '') + '" title="Credits earned by surfing on their own (ad views, daily claims, videos, visits, inbox reads). ' + (m.balance || 0).toLocaleString() + ' still in their earned balance.">' + (m.earned || 0).toLocaleString() + ' cr earned</span>';
|
||||
const walletChip = m => m.activated ? '<span class="lchip on">wallet · payouts on</span>' : m.wallet ? '<span class="lchip warn" title="Wallet linked but payouts not switched on yet: nudge them, their purchases only lock to a sponsor once payouts are on">wallet · payouts off</span>' : '<span class="lchip">no wallet</span>';
|
||||
const memberChips = m => seenChip(m) + ' ' + earnChip(m) + ' ' + walletChip(m);
|
||||
// Section pills at the top of My line: one per visible card marked data-jump, the one in view lit up.
|
||||
// Cards that show or hide themselves (sponsor, upline messages) rebuild the row when they change.
|
||||
let lineJumpObs = null;
|
||||
@@ -491,6 +536,19 @@
|
||||
} catch (e) {}
|
||||
}
|
||||
// visual line tree on the Overview: YOU + three levels, qualified directs in gold
|
||||
function renderRoster(wrap, all) {
|
||||
const rows = listApply('roster', all);
|
||||
wrap.querySelectorAll(':scope > .lst-bar, :scope > table, :scope > .pgr, :scope > .lst-none').forEach(n => n.remove());
|
||||
wrap.appendChild(listBar('roster', all.length, rows.length, () => renderRoster(wrap, all)));
|
||||
if (!rows.length) { wrap.insertAdjacentHTML('beforeend', '<p class="muted small lst-none">Nobody in your line matches those filters.</p>'); return; }
|
||||
const t = document.createElement('table'); t.className = 'roster';
|
||||
t.innerHTML = rows.map(r => '<tr><td>' + esc(r.name || r.email || '') + '</td>'
|
||||
+ '<td><span class="muted">joined</span> ' + new Date(r.joined).toLocaleDateString() + '</td>'
|
||||
+ '<td>' + memberChips(r) + '</td>'
|
||||
+ '<td><span class="badge' + (r.status === 'joined free' ? ' amber' : '') + '">' + esc(r.status) + '</span></td></tr>').join('');
|
||||
wrap.appendChild(t);
|
||||
pageList('roster', wrap, 'table.roster tr', { per: LINE_PER });
|
||||
}
|
||||
async function loadLineTree(buyerCount) {
|
||||
try {
|
||||
const r = await (await fetch('/api/my/line')).json();
|
||||
@@ -624,15 +682,7 @@
|
||||
const wrap = $('rosterWrap');
|
||||
if ((d.referrals || []).length) {
|
||||
$('rosterEmpty').hidden = true;
|
||||
let t = wrap.querySelector('table');
|
||||
if (t) t.remove();
|
||||
t = document.createElement('table');
|
||||
t.className = 'roster';
|
||||
t.innerHTML = d.referrals.map(r => '<tr><td>' + String(r.name || r.email || '').replace(/[&<>]/g, '') + '</td>'
|
||||
+ '<td>' + new Date(r.joined).toLocaleDateString() + '</td>'
|
||||
+ '<td><span class="badge' + (r.status === 'joined free' ? ' amber' : '') + '">' + r.status + '</span></td></tr>').join('');
|
||||
wrap.appendChild(t);
|
||||
pageList('roster', wrap, 'table.roster tr', { per: LINE_PER });
|
||||
renderRoster(wrap, d.referrals);
|
||||
}
|
||||
// overview recent-activity widget: chain events + line joins, newest first
|
||||
try {
|
||||
@@ -1494,19 +1544,26 @@
|
||||
$('tankMine').querySelectorAll('[data-tchat]').forEach(b => b.addEventListener('click', () => openConvo(b.dataset.tchat, b.dataset.tname)));
|
||||
$('tankMine').querySelectorAll('[data-pif]').forEach(b => b.addEventListener('click', () => pif(b.dataset.pif, b.dataset.pname, b.dataset.paddr)));
|
||||
if (!r.waiting.length) { el.innerHTML = '<p class="muted small">The tank is empty. Anyone who joins from the public site without a sponsor lands here.</p>'; return; }
|
||||
el.innerHTML = r.waiting.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + '</span>'
|
||||
+ '<span class="em">joined ' + ago(w.joined) + '</span>'
|
||||
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
|
||||
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('');
|
||||
pageList('tank', el, ':scope > .lin-row', { per: LINE_PER });
|
||||
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
|
||||
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the InstantAdPay holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
|
||||
if (note === null) return;
|
||||
try { const rr = await api('/api/my/tank/adopt', { who: b.dataset.adopt, note }); IAP.status('You are now the sponsor for ' + rr.name + '. Chat and email sent.', 'ok'); loadTank(); loadCoach(); }
|
||||
catch (e) { IAP.status(e.message, 'bad'); }
|
||||
}));
|
||||
renderTank(el, r);
|
||||
} catch (e) {}
|
||||
}
|
||||
function renderTank(el, r) {
|
||||
const rows = listApply('tank', r.waiting);
|
||||
el.innerHTML = '';
|
||||
el.appendChild(listBar('tank', r.waiting.length, rows.length, () => renderTank(el, r), { hide: ['payouts'] })); // nobody in the tank has payouts on
|
||||
el.insertAdjacentHTML('beforeend', rows.length ? rows.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + '</span>'
|
||||
+ '<span class="em">joined ' + ago(w.joined) + '<span class="sp wrap">' + memberChips(w) + '</span></span>'
|
||||
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
|
||||
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('')
|
||||
: '<p class="muted small">Nobody in the tank matches those filters.</p>');
|
||||
pageList('tank', el, ':scope > .lin-row', { per: LINE_PER });
|
||||
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
|
||||
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the InstantAdPay holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
|
||||
if (note === null) return;
|
||||
try { const rr = await api('/api/my/tank/adopt', { who: b.dataset.adopt, note }); IAP.status('You are now the sponsor for ' + rr.name + '. Chat and email sent.', 'ok'); loadTank(); loadCoach(); }
|
||||
catch (e) { IAP.status(e.message, 'bad'); }
|
||||
}));
|
||||
}
|
||||
// The announcement cards at the top of the Overview are repeated on a timer, so a member who has read
|
||||
// one can put it away: dismissed for the rest of this browser session, back at the next sign-in
|
||||
// (Marty, 2026-09-22) so a message nobody has acted on is never gone for good.
|
||||
@@ -1817,17 +1874,29 @@
|
||||
el.innerHTML = '<p class="muted small">No one in your downline yet. Share your link and it fills in here.</p>';
|
||||
return;
|
||||
}
|
||||
el.innerHTML = r.levels.map(L => !L.members.length ? '' :
|
||||
LINE_DATA = r; renderLineage(el);
|
||||
} catch (e) {}
|
||||
}
|
||||
let LINE_DATA = null;
|
||||
function renderLineage(el) {
|
||||
const r = LINE_DATA; if (!r) return;
|
||||
try {
|
||||
const all = r.levels.reduce((n, L) => n + L.members.length, 0);
|
||||
const shown = r.levels.map(L => ({ level: L.level, members: listApply('line', L.members) }));
|
||||
const kept = shown.reduce((n, L) => n + L.members.length, 0);
|
||||
el.innerHTML = '';
|
||||
el.appendChild(listBar('line', all, kept, () => renderLineage(el)));
|
||||
el.insertAdjacentHTML('beforeend', !kept ? '<p class="muted small">Nobody in your downline matches those filters.</p>' : shown.map(L => !L.members.length ? '' :
|
||||
'<div class="lin-lvl"><div class="cap">Level ' + L.level + ' · ' + L.members.length + (L.level === 1 ? ' direct' : '') + '</div>'
|
||||
+ L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + '</span>'
|
||||
+ '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$20+ buy ✓' : 'no $20+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span>') + '</span>'
|
||||
+ '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$20+ buy ✓' : 'no $20+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span><span class="sp wrap">' + memberChips(m) + '</span>') + '</span>'
|
||||
+ '<span class="earn' + (m.earnedWei && m.earnedWei !== '0' ? ' on' : '') + '" title="POL this person has paid you so far">'
|
||||
+ (m.earnedWei && m.earnedWei !== '0' ? '+' + IAP.fmtPol(m.earnedWei) + ' POL' : '0.00 POL') + '</span>'
|
||||
+ '<span class="dt">' + new Date(m.joined).toLocaleDateString() + '</span>'
|
||||
+ (m.email ? '<button class="btn sec small chat-msg-btn" type="button" data-cemail="' + esc(m.email) + '" data-cname="' + esc(m.name) + '">Message</button>' : '')
|
||||
+ (m.ref && !m.own ? '<button class="btn sec small lin-act-btn" type="button" data-act="' + esc(m.ref) + '" aria-expanded="false" title="Activity">Activity ▾</button>' : '')
|
||||
+ '</div>' + (m.ref && !m.own ? '<div class="lin-act" data-actbox="' + esc(m.ref) + '" hidden></div>' : '')).join('')
|
||||
+ '</div>').join('');
|
||||
+ '</div>').join(''));
|
||||
el.querySelectorAll('[data-cemail]').forEach(b =>
|
||||
b.addEventListener('click', () => openConvo(b.dataset.cemail, b.dataset.cname)));
|
||||
el.querySelectorAll('[data-act]').forEach(b => b.addEventListener('click', () => toggleLineActivity(b)));
|
||||
|
||||
@@ -485,6 +485,19 @@ textarea{resize:vertical;font:inherit}
|
||||
.lin-row .sp{display:block;font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .lin-row .em{min-width:0}
|
||||
.lin-row .dt{font-size:12px;color:var(--muted);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
||||
.lin-row .chat-msg-btn{justify-self:end}
|
||||
.lin-row .sp.wrap{white-space:normal;line-height:1.7}
|
||||
/* list toolbar: sort + filter chips shared by the tank, roster and downline (2026-09-29) */
|
||||
.lst-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin:4px 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:rgba(255,255,255,.025)}
|
||||
.lst-sort{font-size:12px;color:var(--muted);display:inline-flex;align-items:center;gap:6px}
|
||||
.lst-sort select{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 8px;font-size:12.5px}
|
||||
.lst-dir{background:transparent;color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 9px;font-size:12px;cursor:pointer;white-space:nowrap}
|
||||
.lst-chips{display:flex;flex-wrap:wrap;gap:6px}
|
||||
.lst-chip{font-size:12px;color:var(--muted);background:transparent;border:1px solid var(--line);border-radius:999px;padding:3px 10px;cursor:pointer;white-space:nowrap}
|
||||
.lst-chip.on{border-color:var(--mint);color:var(--ink);background:var(--mint-soft)}
|
||||
.lst-n{margin-left:auto;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
|
||||
.lchip{display:inline-block;font-size:11.5px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:1px 8px;white-space:nowrap;vertical-align:middle}
|
||||
.lchip.on{border-color:rgba(67,232,195,.45);color:var(--ink)} .lchip.warn{border-color:rgba(255,209,92,.55);color:#ffd15c}
|
||||
.roster td:nth-child(3){white-space:normal;line-height:1.8}
|
||||
.lin-row .lin-act-btn{justify-self:end;white-space:nowrap}
|
||||
.lin-act{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:8px 10px 10px;margin:-1px 0 6px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.025);border-radius:0 0 10px 10px}
|
||||
.lin-chip{font-size:12px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:3px 10px;white-space:nowrap} .lin-chip b{font-weight:600;color:var(--ink);margin-right:5px} .lin-chip.on{border-color:rgba(67,232,195,.45);color:var(--ink)} .lin-chip.warn{border-color:rgba(255,209,92,.5)}
|
||||
|
||||
+4
-3
@@ -5,7 +5,7 @@
|
||||
<title>Member area | InstantAdPay</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260926a">
|
||||
<link rel="stylesheet" href="/assets/site.css?v=20260929a">
|
||||
</head>
|
||||
<body class="bo-body">
|
||||
|
||||
@@ -319,7 +319,8 @@
|
||||
</div>
|
||||
<div class="card" id="lineRosterCard" data-jump="Your line">
|
||||
<h3>Your line</h3>
|
||||
<p class="muted small">Everyone who joined through your link, newest first. When they buy their
|
||||
<p class="muted small">Everyone who joined through your link. Sort or filter the list to spot who signed in today, who is earning
|
||||
credits on their own, and who has a wallet linked but payouts still off. When they buy their
|
||||
first package of $20 or more, they count toward your qualification.</p>
|
||||
<div id="rosterWrap"><p class="muted small" id="rosterEmpty">Nobody yet. Your link is ready above; share it and this list starts filling.</p></div>
|
||||
</div>
|
||||
@@ -1084,7 +1085,7 @@
|
||||
<script src="/assets/common.js?v=20260923b"></script><script src="/assets/welcome.js?v=20260923b"></script>
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20260929c"></script>
|
||||
<script src="/assets/my.js?v=20260929f"></script>
|
||||
<script src="/assets/my.js?v=20260929g"></script>
|
||||
<script src="/assets/chat.js?v=20260907l"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -494,7 +494,7 @@ async function boot() {
|
||||
notify: async (memberId, subject, text, kind) => { const a = await accounts.byMemberId(memberId); if (!a || !a.email) return; const html = '<p>' + String(text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>').split('\n\n').join('</p><p>').replace(/\n/g, '<br>') + '</p>'; await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], subject, html, kind || 'notice'); } });
|
||||
setInterval(() => wednesday.tick().catch(e => console.error('wednesday', e.message)), 5 * 60 * 1000);
|
||||
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
|
||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, site: 'https://instantadpay.com' });
|
||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, ads, site: 'https://instantadpay.com' });
|
||||
await fraud.init({ dataDir: DATA_DIR });
|
||||
{ // a suspended account is signed out everywhere: every member route sees no session
|
||||
const realFrom = auth.fromRequest.bind(auth);
|
||||
@@ -1752,10 +1752,14 @@ const server = http.createServer(async (req, res) => {
|
||||
if (acct && acct.username) refs.push(acct.username);
|
||||
if (memberId) refs.push(String(memberId));
|
||||
const joined = await accounts.listByReferrer(refs);
|
||||
const rTot = await ads.earnedTotals(joined.map(r => r.email)); // surf earnings per referral (Marty, 2026-09-29)
|
||||
out.referrals = joined.map(r => ({
|
||||
name: r.username || r.email.replace(/^(.).*(@.*)$/, '$1***$2'), // username, else privacy mask
|
||||
joined: r.created,
|
||||
status: r.address ? 'wallet linked' : 'joined free'
|
||||
lastSeen: r.lastSeen || 0,
|
||||
wallet: !!r.address, activated: !!r.memberId,
|
||||
earned: (rTot[r.email] || {}).earned || 0, balance: (rTot[r.email] || {}).balance || 0,
|
||||
status: r.memberId ? 'payouts on' : r.address ? 'wallet linked' : 'joined free'
|
||||
}));
|
||||
out.isAdmin = !!(ADMIN_EMAIL && out.email && String(out.email).toLowerCase() === ADMIN_EMAIL); // shows the Admin link
|
||||
out.wallUnlocked = wallUnlockedFor(out.buyerCount || 0); // how many wall positions are the member's own
|
||||
@@ -2404,6 +2408,7 @@ const server = http.createServer(async (req, res) => {
|
||||
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 lTot = await ads.earnedTotals(levels.flatMap(L => L.members.map(m => m.email))); // surf earnings per person (Marty, 2026-09-29)
|
||||
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 => ({
|
||||
@@ -2414,6 +2419,9 @@ const server = http.createServer(async (req, res) => {
|
||||
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
|
||||
joined: m.created,
|
||||
lastSeen: m.lastSeen || 0,
|
||||
wallet: !!m.address, activated: !!m.memberId,
|
||||
earned: (lTot[m.email] || {}).earned || 0, balance: (lTot[m.email] || {}).balance || 0,
|
||||
qualified: idsOf(m).some(id => qualified.has(id)),
|
||||
earnedWei: idsOf(m).reduce((n, id) => n + BigInt(earnedBy[id] || '0'), 0n).toString() })) }));
|
||||
// the member's own linked positions sit on level 1 too, labelled as theirs
|
||||
@@ -3117,7 +3125,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/admin/members' && req.method === 'GET') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const members = await accounts.listAll(500);
|
||||
const members = await accounts.listAll(5000); // was 500: older members (igor147, joined 09-12) vanished from the table and its search once the site passed 500 accounts (Marty, 2026-09-29)
|
||||
// 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)
|
||||
|
||||
@@ -57,7 +57,8 @@ const D = {
|
||||
const rowA = r => ({ id: r.id, adoptee: r.adoptee, adopter: r.adopter, ts: Number(r.ts), expires: Number(r.expires), status: r.status, note: r.note || null, closed: r.closed ? Number(r.closed) : null });
|
||||
const impl = () => db.enabled() ? D : J;
|
||||
|
||||
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; if (opts.site) siteUrl = opts.site; J.load(); }
|
||||
let ads = null;
|
||||
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; ads = opts.ads || null; if (opts.site) siteUrl = opts.site; J.load(); }
|
||||
|
||||
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
|
||||
const nameOf = a => a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : mask(a.email));
|
||||
@@ -65,8 +66,13 @@ const inTank = a => !a.sponsorRef && !a.memberId; // arrived with no sponsor (or
|
||||
|
||||
// waiting list: newest sign-in first so a live one is easy to spot
|
||||
async function waiting() {
|
||||
const all = await accounts.listAll(2000);
|
||||
return all.filter(inTank).map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0, wallet: false }))
|
||||
const all = await accounts.listAll(5000);
|
||||
const rows = all.filter(inTank);
|
||||
// what each of them has earned by surfing on their own, no sponsor (Marty, 2026-09-29), so an adopter can spot the workers
|
||||
const tot = ads && ads.earnedTotals ? await ads.earnedTotals(rows.map(a => a.email)) : {};
|
||||
return rows.map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0,
|
||||
wallet: !!a.address, activated: !!a.memberId, // in the tank "activated" is always false (payouts on = out of the tank); wallet can still be linked
|
||||
earned: (tot[a.email] || {}).earned || 0, balance: (tot[a.email] || {}).balance || 0 }))
|
||||
.sort((a, b) => (b.lastSeen || b.joined) - (a.lastSeen || a.joined));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user