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:
@@ -0,0 +1,44 @@
|
||||
// Admin > Launch week (2026-11-05): Founder badge preview + grant, launch contest standings and the "Pay launch contest" button.
|
||||
// The pay button sends real POL from the Level 4 override payer wallet. It shows the frozen ranking and amounts first and
|
||||
// sends exactly that list; the server refuses if anything changed, and every place is paid at most once.
|
||||
(function () {
|
||||
const $ = IAP.$;
|
||||
if (!$('lwCard')) return;
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||
async function api(path, body) {
|
||||
const r = await (await fetch(path, body === undefined ? { cache: 'no-store' } : { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })).json();
|
||||
if (r.error) throw new Error(r.error === 'auth' ? 'Session expired. Sign in again.' : r.error);
|
||||
return r;
|
||||
}
|
||||
let last = null;
|
||||
async function load() {
|
||||
let r; try { r = await api('/api/admin/launch-week'); } catch (e) { $('lwFounder').textContent = 'Could not read launch week: ' + e.message; return; }
|
||||
last = r;
|
||||
const f = r.founder || {};
|
||||
$('lwFounder').innerHTML = '<b>Founder badge</b> (cosmetic): accounts whose earliest signed-in visit (' + esc(f.field) + ') is before ' + esc(f.launchAtCT) + ' Central. '
|
||||
+ '<b>' + (f.qualify || 0) + '</b> qualify today of ' + (f.accounts || 0) + ' accounts (' + (f.neverSignedIn || 0) + ' never signed in). Granted: ' + (f.granted || 0) + ', still to grant: ' + (f.missing || 0) + '. '
|
||||
+ (f.launched ? 'Launch has passed; the automatic grant runs every 10 minutes' : 'The automatic grant starts at the launch moment') + (f.autoGrant ? '.' : ' (switched OFF: founderGrant = 0).');
|
||||
$('lwGrant').hidden = !f.launched;
|
||||
const w = r.window || {};
|
||||
$('lwWindow').innerHTML = '<b>Launch week contest</b>: ' + esc(w.startCT) + ' to ' + esc(w.endCT) + ' Central · ' + (w.open ? (w.started ? 'OPEN' : 'not started') : 'CLOSED')
|
||||
+ ' · minimum ' + r.minSales + ' sales to place · prizes ' + (r.prizes || []).map((p, i) => (i + 1) + ': ' + p + ' POL').join(', ')
|
||||
+ ' · excluded: ' + esc((r.excluded.emails || []).join(', ')) + ' and member #' + esc((r.excluded.ids || []).join(', #'))
|
||||
+ ' · payer ' + (r.payer.keyPresent ? esc(r.payer.address) + ' holds ' + esc(r.payer.balancePol || '?') + ' POL' : 'NOT configured');
|
||||
$('lwStand').innerHTML = (r.standings || []).length ? '<table><tr><th>#</th><th>Member</th><th>Pays to</th><th>Sales</th><th>$</th><th>Places?</th></tr>' + r.standings.map(x => '<tr><td>' + x.rank + '</td><td>' + esc(x.name) + ' <span class="muted">' + esc(x.email) + '</span></td><td>#' + x.memberId + '</td><td>' + x.sales + '</td><td>$' + x.usd + '</td><td>' + (x.qualifies ? 'yes' : 'no') + '</td></tr>').join('') + '</table>' : '<p class="muted">No counted sales in the window yet.</p>';
|
||||
$('lwPayouts').innerHTML = (r.payouts || []).length ? '<p><b>Payout records</b> (frozen ' + new Date(r.frozen.at).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT)</p><table><tr><th>Place</th><th>Member</th><th>POL</th><th>State</th><th>Tx</th></tr>' + r.payouts.map(x => '<tr><td>' + x.place + '</td><td>' + esc(x.name) + ' #' + x.memberId + '</td><td>' + esc(x.pol) + '</td><td>' + esc(x.state) + (x.note ? ' <span class="muted">' + esc(x.note) + '</span>' : '') + '</td><td>' + (x.tx ? '<a href="' + esc(x.tx) + '" target="_blank" rel="noopener">tx</a>' : '') + '</td></tr>').join('') + '</table>' : '';
|
||||
$('lwPay').hidden = !r.canPay || !(r.wouldPay || []).length || (r.payouts || []).length && r.payouts.every(x => x.state === 'paid');
|
||||
}
|
||||
$('lwRefresh').addEventListener('click', load);
|
||||
$('lwGrant').addEventListener('click', async () => {
|
||||
try { const r = await api('/api/admin/launch-week/founders', {}); IAP.status('Founder badge: granted to ' + (r.granted || 0) + ' accounts' + (r.skipped ? ' (' + r.skipped + ')' : '') + '.', 'ok'); load(); } catch (e) { IAP.status(e.message, 'bad'); }
|
||||
});
|
||||
$('lwPay').addEventListener('click', async () => {
|
||||
await load(); if (!last) return;
|
||||
const list = last.wouldPay || []; if (!list.length) { IAP.status('Nobody placed: nothing to pay.', 'bad'); return; }
|
||||
const total = list.reduce((n, x) => n + Number(x.pol), 0);
|
||||
const text = list.map(x => 'Place ' + x.place + ': ' + x.name + ' (member #' + x.memberId + ', ' + x.sales + ' sales) gets ' + x.pol + ' POL').join('\n') + '\n\nTotal ' + total + ' POL plus gas, sent from the payer wallet with award(memberId). Each place is paid once.';
|
||||
if (!await IAP.confirmBox(text, { title: 'Pay the launch week contest?', ok: 'Pay ' + total + ' POL', cancel: 'Cancel' })) return;
|
||||
try { const r = await api('/api/admin/launch-week/pay', { confirm: true, places: list.map(x => ({ place: x.place, memberId: x.memberId, pol: x.pol })) }); IAP.status('Launch contest: ' + (r.paidNow || 0) + ' paid now.', 'ok'); load(); } catch (e) { IAP.status(e.message, 'bad'); load(); }
|
||||
});
|
||||
load();
|
||||
})();
|
||||
+10
-6
@@ -83,7 +83,9 @@
|
||||
{ key: 'payouts', label: 'Spark', sub: 'payouts on', img: '/badges/badge-spark.jpg', ribbonY: 0.873 },
|
||||
{ key: 'firstBuyer', label: 'Surge', sub: 'first qualifying buyer', img: '/badges/badge-surge.jpg?v=2', ribbonY: 0.873 },
|
||||
{ key: 'level2', label: 'Circuit', sub: '2 qualifying buyers', img: '/badges/badge-circuit.jpg?v=2', ribbonY: 0.873 },
|
||||
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.873 }
|
||||
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.873 },
|
||||
// Founder (2026-11-05): cosmetic, stored on the account, granted at the launch moment to everyone who signed in before it
|
||||
{ key: 'founder', label: 'Founder', sub: 'in before launch', img: '/badges/badge-founder.jpg?v=1', ribbonY: 0.873, extra: true }
|
||||
];
|
||||
let lastMilestones = [];
|
||||
function renderBadges(d) {
|
||||
@@ -92,12 +94,14 @@
|
||||
const strip = $('badgeStrip');
|
||||
if (!strip) return;
|
||||
$('badgeCard').hidden = false;
|
||||
strip.innerHTML = BADGES.map(b => {
|
||||
const got = reached.includes(b.key);
|
||||
const held = reached.concat(d.founder ? ['founder'] : []);
|
||||
strip.innerHTML = BADGES.filter(b => !b.extra || d.founder || d.founderPending).map(b => {
|
||||
const got = held.includes(b.key);
|
||||
return '<div class="badge-a' + (got ? '' : ' locked') + '">'
|
||||
+ '<img class="badge-img" src="' + b.img + '" alt="' + b.label + ' badge" loading="lazy">'
|
||||
+ '<div class="bl">' + b.label + '</div><div class="bs">' + b.sub + '</div>'
|
||||
+ (got ? '<button class="share" data-badge="' + b.key + '">Share</button> <button class="share" data-badgepost="' + b.key + '" hidden>Post to Telegram</button>' : '<div class="bs">🔒 locked</div>') + '</div>';
|
||||
+ (got ? '<button class="share" data-badge="' + b.key + '">Share</button>' + (b.extra ? '' : ' <button class="share" data-badgepost="' + b.key + '" hidden>Post to Telegram</button>')
|
||||
: b.key === 'founder' ? '<div class="bs">arrives at launch, Sunday Nov 15</div>' : '<div class="bs">🔒 locked</div>') + '</div>';
|
||||
}).join('');
|
||||
strip.querySelectorAll('[data-badge]').forEach(btn =>
|
||||
btn.addEventListener('click', () => shareBadge(btn.dataset.badge, d)));
|
||||
@@ -1547,7 +1551,7 @@
|
||||
}
|
||||
el.innerHTML = r.levels.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>'
|
||||
+ L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + (m.founder ? ' <span class="badge" title="Founder badge: signed in before LinkSpin launched" style="background:#ffc94d;border-color:#ffc94d;color:#5a3f00">Founder</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 ? '$25+ buy ✓' : 'no $25+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</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>'
|
||||
@@ -1584,7 +1588,7 @@
|
||||
+ chip('Link', (a.linkViews30 || 0) + ' views (30d) · ' + (a.joins || 0) + ' joined', (a.linkViews30 || 0) > 0 ? 'on' : '')
|
||||
+ chip('Line', (a.directs || 0) + ' direct' + (a.directs === 1 ? '' : 's') + ' · ' + (a.buyerCount || 0) + ' qualifying', (a.buyerCount || 0) > 0 ? 'on' : '')
|
||||
+ chip('Wallet', a.wallet ? (a.badges && a.badges.includes('payouts') ? 'linked · payouts on' : 'linked') : 'not linked', a.wallet ? '' : 'warn')
|
||||
+ (a.badges && a.badges.length ? chip('Badges', a.badges.map(b => ({ payouts: 'Spark', firstBuyer: 'Surge', level2: 'Circuit', level3: 'Nexus' }[b] || b)).join(' · ')) : '')
|
||||
+ (a.badges && a.badges.length ? chip('Badges', a.badges.map(b => ({ payouts: 'Spark', firstBuyer: 'Surge', level2: 'Circuit', level3: 'Nexus', founder: 'Founder' }[b] || b)).join(' · ')) : '')
|
||||
+ '<span class="lin-verdict' + (working ? ' on' : '') + '">' + (working ? 'Working' : 'Quiet') + '</span>';
|
||||
}
|
||||
async function loadUplineMessages() {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
const ms = rows(); const L = (LINE && LINE.levels || []).find(x => x.level === LEVEL); const total = L ? L.members.length : 0;
|
||||
$('rows').innerHTML = ms.length ? ms.map(m => { const today = (m.lastSeen || 0) >= dayStart();
|
||||
const sg = stageOf(m), q = quiet(m);
|
||||
return '<div class="rw st-row' + (q ? ' stalled' : '') + '" data-st="' + sg + '"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $25+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span></div>'
|
||||
return '<div class="rw st-row' + (q ? ' stalled' : '') + '" data-st="' + sg + '"><div><b>' + esc(m.name) + (m.own ? ' <span class="tag dim">YOURS</span>' : '') + (m.founder ? ' <span class="tag" title="Founder badge: signed in before LinkSpin launched" style="background:#ffc94d;color:#5a3f00">FOUNDER</span>' : '') + '</b><br><span class="mono muted" style="font-size:11px">' + (m.memberId ? '#' + m.memberId + ' · ' : '') + 'joined ' + new Date(m.joined).toLocaleDateString() + (m.bought ? ' · $25+ buy' : '') + (m.buyers ? ' · ' + m.buyers + ' qualifying' : '') + '</span></div>'
|
||||
+ '<span class="mono ' + (today ? 'ok' : (m.lastSeen && Date.now() - m.lastSeen > 3 * 86400e3 ? 'warn' : '')) + '" style="font-size:12px">' + (today ? 'today' : ago(m.lastSeen)) + '</span>'
|
||||
+ '<span><span class="stg" data-st="' + sg + '">' + STAGE[sg] + '</span>' + (q ? '<br><span class="stg quiet">' + (m.lastSeen ? 'quiet ' + Math.floor((Date.now() - m.lastSeen) / 86400e3) + 'd' : 'never signed in') + '</span>' : '') + '</span>'
|
||||
+ '<span class="r num">' + (m.earnedWei && m.earnedWei !== '0' ? '+' + pol(m.earnedWei) + ' POL' : '<span class="muted">0</span>') + '</span>'
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// The Founder badge on a member's wall (2026-11-05, cosmetic). Kept apart from wall.js, which a shared policy test pins by version.
|
||||
(async function () {
|
||||
const img = document.getElementById('bioFounder'); if (!img) return;
|
||||
const name = location.pathname.split('/').pop();
|
||||
try {
|
||||
const w = await (await fetch('/api/wall/' + encodeURIComponent(name))).json();
|
||||
if (w && w.founder && w.founder.img) { img.src = w.founder.img; img.title = 'Founder badge: signed in before LinkSpin launched'; img.hidden = false; }
|
||||
} catch (e) {}
|
||||
})();
|
||||
Reference in New Issue
Block a user