Tank batches deal the warmest leads first (hub heat score, ties in tank order; Marty 2026-11-19)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-19 04:46:30 -06:00
parent 52f0a5496b
commit f8f05e22b5
+8 -3
View File
@@ -14,8 +14,8 @@
// "at a time" a sponsor holds at most one batch size of batch people who have not switched on payouts; a person who
// switches on payouts frees their place at once
// cadence every tankBatchEveryDays (2) per sponsor a fresh batch tops them back up to their size. One round deals by
// rotation, highest tier first (ties: longest since their last batch), one person per sponsor per pass, from
// the waiting tank in the order the tank already uses (tank.adoptable: past the 24-hour sign-up grace, rule 3
// rotation, highest tier first (ties: longest since their last batch), one person per sponsor per pass, warmest
// first (hub heat score, ties in tank order) from the waiting tank (tank.adoptable: past the 24-hour sign-up grace, rule 3
// applied, nobody adopted on LinkSpin). Never: the sponsor themself, anyone above them in their own line, anyone
// adopted twice, a flagged, spam, throwaway or unsubscribed address
// assignment tank.adopt(.., { batch: true }): the same sponsor change, chat, "X is now your sponsor" email and switch-on-payouts
@@ -31,6 +31,7 @@
// still runs for batch people already assigned (they must not sit uncontacted). preview() is read-only whatever the switch says.
const fs = require('fs');
const path = require('path');
const tankready = require('./tankready');
const D = 86400000;
const DEFAULTS = {
@@ -201,7 +202,7 @@ async function sponsors(c, now) {
return { list: out, skipped, why };
}
// the waiting people a batch may take, in the tank's own order
// the waiting people a batch may take, warmest first
async function poolOf() {
const list = await R.tank.adoptable(); const local = await R.tank.summaryMap(); const ex = {}; const rows = [];
const no = k => { ex[k] = (ex[k] || 0) + 1; };
@@ -213,6 +214,10 @@ async function poolOf() {
if (px) { no(px); continue; }
rows.push(w);
}
// warmest first (Marty 2026-11-19): the hub heat score from the tank card (tankready.js). No reading (hub down) counts as 0,
// so ties and a dark hub keep the tank's own order
const heat = new Map((await tankready.attach(rows, 4000)).map(w => [w.email, w.rd && w.rd.heat ? Number(w.rd.heat.score) || 0 : 0]));
rows.sort((a, b) => (heat.get(b.email) || 0) - (heat.get(a.email) || 0));
return { waiting: list.length, rows, excluded: ex };
}