Launch week: Founder badge + launch week contest (Marty approved 2026-11-05, PLAN.md options B and C)
Founder badge (cosmetic only: no credits, no POL, no perks, never posted to Telegram) - Criterion: the account's earliest signed-in visit is before the launch moment (launchAt, default 2026-11-15T06:00:00-06:00). Field: accounts.firstSeen, else lastSeen. Both are written only by accounts.touchSeen() on signed-in requests (dashboard, ping, chat); touchSeen now keeps firstSeen = the previous lastSeen on the next visit, so a pre-launch member who signs in again after launch still qualifies. Carried-over shells that never signed in have neither field and never qualify. - Stored flag accounts.founder (JSON + MySQL column). Grant: launchweek.tick every 10 minutes from the launch moment, idempotent, one run per 10-minute slot across app copies (marks.claim); founderGrant '0' turns it off. Admin preview + "Grant Founder badges now" (refused before launch). - Shown in the badge strip (on the way before launch, Share works, no Telegram post), wall (wall-founder.js), Team rows (my.js + team.js), the Team activity chip, and next to names on /leaderboard. Art: /badges/badge-founder.jpg, drawn in code in the existing card layout. Launch week contest - Window [launchContestStart or launchAt, launchContestEnd) = Sun Nov 15 6:00 AM to the end of Sat Nov 21, Central (end stored exclusive, 2026-11-22T00:00:00-06:00). Count = the weekly board's tier-1 TierPaid sales. Never counted: own positions, buys by linked positions (Qualified Start), the admin account and overrideHouseIds (as contestants or buyers), launchContestExcludeEmails/Ids. launchContestMinSales 2. Ties: sales, dollars, who got there first. Prizes launchContestPrizesPol '10,6,4'. - Payout only by Admin > Launch week > Pay launch contest: the ranking is frozen on the first press, the admin's confirmed list must match it, balance + gas checked first, each place claimed once (marks.claim) and written as sending before award(memberId) from the Level 4 override payer wallet (override.payerHandle). Records tx hashes; resolve paid-with-tx or retry for blocked/failed/review. The prize email + feed line say "Launch week contest prize". - /leaderboard panel from the launch moment until the prizes are paid; /launch copy states both rules. - chatbot: CANNED founder-badge + launch-contest, FACTS lines (no amounts quoted before launch). - qa/launchweek.test.cjs (16 checks: Central window bounds, exclusions, minimum, two-copy payout once, frozen result, Founder criterion + grant, touchSeen backfill); run.sh launchweek and in all. - Versions: my.js?v=20261105fd, team.js?v=20261105fd, wall-founder.js?v=20261105fd, admin-launchweek.js?v=20261105lw (wall.js unchanged: the shared policy test pins it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+17
-12
@@ -38,14 +38,15 @@ function periodBounds(period, ts) {
|
||||
let idMap = { at: 0, map: {}, names: {} };
|
||||
async function memberMap() {
|
||||
if (Date.now() - idMap.at < 60000) return idMap;
|
||||
const map = {}, names = {};
|
||||
const list = await R.accounts.listAll(5000);
|
||||
const map = {}, names = {}, founders = new Set(), positionIds = new Set(), mainId = {};
|
||||
const list = await R.accounts.listAll(50000);
|
||||
for (const a of list) {
|
||||
if (a.memberId) { map[a.memberId] = a.email; names[a.email] = a.username ? '@' + a.username : 'member #' + a.memberId; }
|
||||
if (a.memberId) { map[a.memberId] = a.email; mainId[a.email] = a.memberId; names[a.email] = a.username ? '@' + a.username : 'member #' + a.memberId; }
|
||||
else names[a.email] = a.username ? '@' + a.username : a.email.replace(/@.*/, '') + '@';
|
||||
try { for (const p of await R.accounts.positions(a.email)) if (p.memberId) map[p.memberId] = a.email; } catch (e) {}
|
||||
if (a.founder) founders.add(a.email); // Founder badge (2026-11-05): shown next to the name on the board
|
||||
try { for (const p of await R.accounts.positions(a.email)) if (p.memberId) { map[p.memberId] = a.email; positionIds.add(p.memberId); } } catch (e) {} // linked positions (Qualified Start)
|
||||
}
|
||||
idMap = { at: Date.now(), map, names }; return idMap;
|
||||
idMap = { at: Date.now(), map, names, founders, positionIds, mainId }; return idMap;
|
||||
}
|
||||
|
||||
const computeCache = {};
|
||||
@@ -55,7 +56,7 @@ async function compute(period) {
|
||||
}
|
||||
async function computeRaw(period) {
|
||||
const { start, end, label } = periodBounds(period);
|
||||
const { map, names } = await memberMap();
|
||||
const { map, names, founders } = await memberMap();
|
||||
const price = {}; // tx -> cents
|
||||
for (const e of R.chain.recentEvents(1e9)) if (e.type === 'Purchase') price[e.tx + ':' + e.buyerId] = Number(e.priceCents || 0);
|
||||
const rows = {};
|
||||
@@ -77,7 +78,7 @@ async function computeRaw(period) {
|
||||
for (const [em, n] of Object.entries(joins)) { const r = rows[em] = rows[em] || { email: em, name: names[em] || em, sales: 0, cents: 0, pol: 0n, buyers: new Set() }; r.joins = n; }
|
||||
// the admin's own account (company placements, tank arrivals) is not a contestant
|
||||
if (R.adminEmail && rows[R.adminEmail]) delete rows[R.adminEmail];
|
||||
const out = Object.values(rows).map(r => ({ email: r.email, name: r.name, sales: r.sales, usd: r.cents / 100, pol: Number(r.pol / 10n ** 14n) / 10000, buyers: r.buyers.size, joins: r.joins || 0 }))
|
||||
const out = Object.values(rows).map(r => ({ email: r.email, name: r.name, founder: founders.has(r.email), sales: r.sales, usd: r.cents / 100, pol: Number(r.pol / 10n ** 14n) / 10000, buyers: r.buyers.size, joins: r.joins || 0 }))
|
||||
.sort((a, b) => b.usd - a.usd || b.sales - a.sales || b.joins - a.joins);
|
||||
out.forEach((r, i) => { r.rank = i + 1; });
|
||||
return { period, label, start, end, rows: out };
|
||||
@@ -91,7 +92,7 @@ async function view(period, meEmail) {
|
||||
return { period: r.period, label: r.label, start: r.start, end: r.end, prize: prize || '', top: r.rows.slice(0, 10).map(pub), me: me ? pub(me) : null, count: r.rows.length,
|
||||
winners: winners().slice(0, 6) };
|
||||
}
|
||||
const pub = r => ({ rank: r.rank, name: r.name, sales: r.sales, usd: r.usd, buyers: r.buyers, joins: r.joins });
|
||||
const pub = r => ({ rank: r.rank, name: r.name, founder: !!r.founder, sales: r.sales, usd: r.usd, buyers: r.buyers, joins: r.joins });
|
||||
// "1000,500,250" -> [1000, 500, 250]: credits for 1st, 2nd, 3rd... (Marty: award the top X positions, 2026-09-14)
|
||||
const ladder = v => String(v || '').split(',').map(x => Math.round(Number(x)) || 0).filter(n => n > 0);
|
||||
const ORD = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th'];
|
||||
@@ -125,24 +126,28 @@ async function rolloverTick() {
|
||||
}
|
||||
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||
// the Founder badge next to a name (cosmetic, 2026-11-05)
|
||||
const fdr = r => r && r.founder ? ' <span class="fdr" title="Founder badge: signed in before LinkSpin launched">Founder</span>' : '';
|
||||
async function renderPage() {
|
||||
const week = await view('week'), month = await view('month'), all = await view('all');
|
||||
const sc = R.siteConfig();
|
||||
const table = v => '<table class="lb"><tr><th>#</th><th>Member</th><th>Packages</th><th>Sales</th><th>Buyers</th><th>New members</th></tr>'
|
||||
+ (v.top.length ? v.top.map(r => '<tr><td>' + r.rank + '</td><td><b>' + esc(r.name) + '</b></td><td>' + r.sales + '</td><td>$' + r.usd.toLocaleString() + '</td><td>' + r.buyers + '</td><td>' + r.joins + '</td></tr>').join('') : '<tr><td colspan="6" class="muted">No sales yet in this period.</td></tr>') + '</table>';
|
||||
+ (v.top.length ? v.top.map(r => '<tr><td>' + r.rank + '</td><td><b>' + esc(r.name) + '</b>' + fdr(r) + '</td><td>' + r.sales + '</td><td>$' + r.usd.toLocaleString() + '</td><td>' + r.buyers + '</td><td>' + r.joins + '</td></tr>').join('') : '<tr><td colspan="6" class="muted">No sales yet in this period.</td></tr>') + '</table>';
|
||||
const fmtD = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: TZ, month: 'short', day: 'numeric' });
|
||||
const desc = 'Who is selling the most ad packages on LinkSpin this week and this month. Weekly and monthly referral contest standings, read from the chain.';
|
||||
let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Leaderboard | LinkSpin</title><meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + SITE_URL + '/leaderboard"><meta property="og:title" content="LinkSpin leaderboard"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="' + SITE_URL + '/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
|
||||
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=ls20261101t">'
|
||||
+ '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:#ffd15c;font-weight:800}.prize{border-left:4px solid var(--mint);background:rgba(67,232,195,.07);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}</style></head><body><div class="wrap lbw">'
|
||||
+ '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:#ffd15c;font-weight:800}.prize{border-left:4px solid var(--mint);background:rgba(67,232,195,.07);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}.fdr{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:999px;font-size:11px;font-weight:700;letter-spacing:.04em;color:#7a5600;background:#ffc94d;vertical-align:1px}.lwc{border:1px solid #ffc94d;border-radius:14px;padding:16px 18px;margin:0 0 28px;background:rgba(255,201,77,.07)}.lwc h2{margin:0 0 4px;font-size:24px}.lwc .lb{margin-bottom:8px}</style></head><body><div class="wrap lbw">'
|
||||
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Referral contest</p><h1>Leaderboard: <em>who is selling</em>.</h1><p class="lead">Ranked by ad packages sold to other people (your own positions never count, and the company account is not a contestant). Read from the chain, updated live. Weeks run Monday to Sunday, Central time.</p></section>';
|
||||
if (R.launchPanel) { try { h += await R.launchPanel(); } catch (e) { console.error('launch panel', e.message); } } // launch week contest (launchweek.js), date-driven
|
||||
h += '<h2 style="font-size:24px;margin:0 0 4px">' + week.label + ' <span class="muted small">' + fmtD(week.start) + ' to Sunday</span></h2>' + (week.prize ? '<div class="prize"><b>Weekly prizes:</b> ' + esc(week.prize) + '</div>' : '') + table(week);
|
||||
h += '<h2 style="font-size:24px;margin:0 0 4px">' + month.label + '</h2>' + (month.prize ? '<div class="prize"><b>Monthly prizes:</b> ' + esc(month.prize) + '</div>' : '') + table(month);
|
||||
h += '<h2 style="font-size:24px;margin:0 0 4px">All time</h2>' + table(all);
|
||||
const w = winners();
|
||||
if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '</div>').join('');
|
||||
h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Prizes are advertising credits or packages, never cash. No income is guaranteed.</p>';
|
||||
h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Weekly and monthly prizes are advertising credits or packages, never cash. No income is guaranteed.</p>';
|
||||
h += '</div><script src="/assets/common.js?v=20261101t"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
|
||||
return h;
|
||||
}
|
||||
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds };
|
||||
function setLaunchPanel(fn) { if (R) R.launchPanel = fn; }
|
||||
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds, memberMap, setLaunchPanel, ctParts };
|
||||
|
||||
Reference in New Issue
Block a user