From e1d6b782a2cf9cf6266ee7dc4b1852c13c612e63 Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 15 Aug 2026 05:36:14 -0500 Subject: [PATCH] Auto-advance rotation when a sponsor hits 2/2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- server.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/server.js b/server.js index a19e061..d81c2e8 100644 --- a/server.js +++ b/server.js @@ -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)}