Coach nudges never guess from a failed chain read, and the site owner is never coached (Marty 2026-10-31): a chain.member() failure cached null for 60 s, rungFor() then classed the member as "payouts on, no purchase" and mailed the rung-2 "See a payout land: your first package" nudge to the owner (memberId 1, 4 purchases, 7 buyers). describe() now reports unknown and stalled requires a known state; nudgeTick skips adminEmail.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -56,12 +56,16 @@ async function member(id) {
|
|||||||
const STALL_DAYS = 3;
|
const STALL_DAYS = 3;
|
||||||
async function describe(acct, now = Date.now()) {
|
async function describe(acct, now = Date.now()) {
|
||||||
const mm = await member(acct.memberId);
|
const mm = await member(acct.memberId);
|
||||||
|
// unknown = the member is on chain but the read failed just now (member() swallows RPC errors and caches null for a
|
||||||
|
// minute); rungFor would call them "payouts on, no purchase" and the coach would mail a buyer the first-package nudge
|
||||||
|
// (2026-10-31 on LinkSpin: Marty, 4 purchases and 7 buyers, got "See a payout land"). Callers that mail must skip unknown.
|
||||||
|
const unknown = !!(acct.memberId && !mm);
|
||||||
const rung = rungFor(acct, mm);
|
const rung = rungFor(acct, mm);
|
||||||
const last = Math.max(acct.created || 0, acct.lastSeen || 0);
|
const last = Math.max(acct.created || 0, acct.lastSeen || 0);
|
||||||
const quietDays = Math.floor((now - last) / DAY);
|
const quietDays = Math.floor((now - last) / DAY);
|
||||||
const stalled = rung < 6 && quietDays >= STALL_DAYS;
|
const stalled = !unknown && rung < 6 && quietDays >= STALL_DAYS;
|
||||||
const R = RUNGS[rung];
|
const R = RUNGS[rung];
|
||||||
return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, buyerCount: mm ? mm.buyerCount : 0,
|
return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, unknown, buyerCount: mm ? mm.buyerCount : 0,
|
||||||
counted: !!(mm && mm.countedAsBuyer), joined: acct.created, lastSeen: acct.lastSeen || 0, onchainSponsorId: mm ? mm.sponsorId : null };
|
counted: !!(mm && mm.countedAsBuyer), joined: acct.created, lastSeen: acct.lastSeen || 0, onchainSponsorId: mm ? mm.sponsorId : null };
|
||||||
}
|
}
|
||||||
// coaching view for a sponsor: every direct, ladder rung, stalled flag, what to say
|
// coaching view for a sponsor: every direct, ladder rung, stalled flag, what to say
|
||||||
@@ -320,6 +324,7 @@ async function nudgeTick() {
|
|||||||
const all = await accounts.listAll(5000);
|
const all = await accounts.listAll(5000);
|
||||||
for (const acct of all) {
|
for (const acct of all) {
|
||||||
if (!acct.email || !acct.created || now - acct.created < STALL_DAYS * DAY) continue;
|
if (!acct.email || !acct.created || now - acct.created < STALL_DAYS * DAY) continue;
|
||||||
|
if (X.adminEmail && String(acct.email).toLowerCase() === String(X.adminEmail).toLowerCase()) continue; // the site owner is never coached (2026-10-31)
|
||||||
const c = await describe(acct, now);
|
const c = await describe(acct, now);
|
||||||
if (!c.stalled) continue;
|
if (!c.stalled) continue;
|
||||||
const R = RUNGS[c.rung]; if (!R.mail) continue;
|
const R = RUNGS[c.rung]; if (!R.mail) continue;
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ async function boot() {
|
|||||||
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
|
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
|
||||||
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
|
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
|
||||||
// follow-up email sequence: send whatever came due (every 10 min, first pass shortly after boot)
|
// follow-up email sequence: send whatever came due (every 10 min, first pass shortly after boot)
|
||||||
coach.init({ dataDir: DATA_DIR, chain, accounts, mailer, ads, tank, lb: () => leaderboard, siteConfig });
|
coach.init({ dataDir: DATA_DIR, chain, accounts, mailer, ads, tank, lb: () => leaderboard, siteConfig, adminEmail: ADMIN_EMAIL });
|
||||||
pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain });
|
pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain });
|
||||||
translate.init({ dataDir: DATA_DIR });
|
translate.init({ dataDir: DATA_DIR });
|
||||||
tickets.init({ dataDir: DATA_DIR, mailer, messages, accounts, adminEmail: ADMIN_EMAIL, telegram: supportTelegram, translate });
|
tickets.init({ dataDir: DATA_DIR, mailer, messages, accounts, adminEmail: ADMIN_EMAIL, telegram: supportTelegram, translate });
|
||||||
|
|||||||
Reference in New Issue
Block a user