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:
@@ -580,20 +580,29 @@ chain.startIndexer(evt=>{
|
||||
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)}
|
||||
// Auto-count directs (Marty 2026-08-14, "prevent manual effort"): a new
|
||||
// registration whose referrer sits in the rotation queue increments that
|
||||
// sponsor's directs automatically — same operation as the admin ⊕ button.
|
||||
// Deliberately does NOT auto-qualify at 2/2: rotating the team focus stays
|
||||
// a human call, so it alerts instead.
|
||||
// Auto-count directs + AUTO-ADVANCE (Marty 2026-08-15): a new registration
|
||||
// whose referrer sits in the rotation queue increments that sponsor's directs.
|
||||
// When it reaches 2/2 the sponsor is auto-qualified and the next waiting
|
||||
// position activates — no manual Qualify click (changed from the earlier
|
||||
// manual design so the rotation never sits stuck at a 2/2 sponsor).
|
||||
try{
|
||||
if(evt.type==='registered'&&evt.referrerId!=null){
|
||||
const sponsors=getSponsors();
|
||||
let sponsors=getSponsors();
|
||||
const idx=sponsors.findIndex(x=>String(x.id)===String(evt.referrerId));
|
||||
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);
|
||||
saveSponsors(sponsors);
|
||||
const newDirects=Math.min(2,(Number(sponsors[idx].directs)||0)+1);
|
||||
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)}
|
||||
|
||||
Reference in New Issue
Block a user