Auto-advance rotation when a sponsor hits 2/2

Reverses the earlier manual-Qualify design (Marty 2026-08-15): when the
auto-count brings a queue sponsor to 2/2 directs, the sponsor is now
auto-qualified and normalizeStatuses activates the next waiting position
— same as clicking Qualify, but automatic. Previously it stopped at 2/2
"active" and waited for a manual click, which left the rotation looking
stuck (hit live with #36 Mad Dog). #36 qualified manually to catch up;
rotation advanced to #34 Janie.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-15 05:36:14 -05:00
parent 0f5630e6d0
commit e1d6b782a2
+18 -9
View File
@@ -580,20 +580,29 @@ chain.startIndexer(evt=>{
if(rec&&rec.email&&!sent.has(rec.email.toLowerCase()))sendPaidEmail(rec.email,'there',evt,unsubUrl(evt.toId)); if(rec&&rec.email&&!sent.has(rec.email.toLowerCase()))sendPaidEmail(rec.email,'there',evt,unsubUrl(evt.toId));
} }
}catch(e){console.error('paid email error',e.message)} }catch(e){console.error('paid email error',e.message)}
// Auto-count directs (Marty 2026-08-14, "prevent manual effort"): a new // Auto-count directs + AUTO-ADVANCE (Marty 2026-08-15): a new registration
// registration whose referrer sits in the rotation queue increments that // whose referrer sits in the rotation queue increments that sponsor's directs.
// sponsor's directs automatically — same operation as the admin ⊕ button. // When it reaches 2/2 the sponsor is auto-qualified and the next waiting
// Deliberately does NOT auto-qualify at 2/2: rotating the team focus stays // position activates — no manual Qualify click (changed from the earlier
// a human call, so it alerts instead. // manual design so the rotation never sits stuck at a 2/2 sponsor).
try{ try{
if(evt.type==='registered'&&evt.referrerId!=null){ if(evt.type==='registered'&&evt.referrerId!=null){
const sponsors=getSponsors(); let sponsors=getSponsors();
const idx=sponsors.findIndex(x=>String(x.id)===String(evt.referrerId)); const idx=sponsors.findIndex(x=>String(x.id)===String(evt.referrerId));
if(idx>=0&&sponsors[idx].status!=='qualified'&&(Number(sponsors[idx].directs)||0)<2){ if(idx>=0&&sponsors[idx].status!=='qualified'&&(Number(sponsors[idx].directs)||0)<2){
sponsors[idx].directs=Math.min(2,(Number(sponsors[idx].directs)||0)+1); const newDirects=Math.min(2,(Number(sponsors[idx].directs)||0)+1);
saveSponsors(sponsors);
const s=sponsors[idx]; const s=sponsors[idx];
sendTelegram(`🤖 AUTO-COUNT: #${evt.id} is a DIRECT for queue sponsor #${s.id}${s.name?` (${s.name})`:''} — now ${s.directs}/2.${s.directs>=2?'\n🎯 2/2 reached — open /admin and hit Qualify when you want the rotation to move.':''}`); if(newDirects>=2){
sponsors[idx]={...sponsors[idx],directs:2,status:'qualified'};
sponsors=normalizeStatuses(sponsors);
saveSponsors(sponsors);
const next=activeSponsor(sponsors);
sendTelegram(`✅ AUTO-ADVANCE: queue sponsor #${s.id}${s.name?` (${s.name})`:''} reached 2/2 and is now QUALIFIED.\nRotation moved to ${next?`#${next.id}${next.name?` (${next.name})`:''}`:'— nobody waiting (add the next position to the queue)'}.`);
}else{
sponsors[idx].directs=newDirects;
saveSponsors(sponsors);
sendTelegram(`🤖 AUTO-COUNT: #${evt.id} is a DIRECT for queue sponsor #${s.id}${s.name?` (${s.name})`:''} — now ${newDirects}/2.`);
}
} }
} }
}catch(e){console.error('auto-direct error',e.message)} }catch(e){console.error('auto-direct error',e.message)}