Weekly award asks InstantAdPay fresh for every contender's Game Pass before deciding (the stored copy said @bizventures had no pass while InstantAdPay had it active to 11-27, costing him 2nd place for the week of 11-16); no answer = wait for the next tick, never decide on the stored copy; a repeated grant ref no longer overwrites the stored pass with its old value
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
+20
-1
@@ -133,8 +133,27 @@ function awardFill(monday) {
|
||||
return { week: monday, winners: added, filled: added.length };
|
||||
}
|
||||
// on every tick: the most recent completed week gets awarded on the first tick after it ends
|
||||
function awardDue(notify) {
|
||||
// 2026-11-23: before the award, every hunter who could win (minimum finds reached) has their Game Pass asked fresh from InstantAdPay,
|
||||
// because awardWeek reads the stored copy and a stale "no pass" cost @bizventures 2nd place. If InstantAdPay does not answer for any
|
||||
// of them, nothing is awarded on this tick and the next tick (2 minutes) tries again.
|
||||
let awarding = false;
|
||||
async function awardDue(notify) {
|
||||
const last = dayMinus(weekOf(ctDay()), 7);
|
||||
if (awarding || store.read('prizes', []).some(x => x.week === last)) return null;
|
||||
awarding = true;
|
||||
try {
|
||||
let gp = null; try { gp = require('./polgrant'); } catch (e) {}
|
||||
if (gp && gp.on && gp.on() && gp.freshPass) {
|
||||
const rules = prizeRules();
|
||||
for (const r of weekRows(last).filter(x => x.finds >= rules.minFinds)) {
|
||||
const f = await gp.freshPass(r.memberId, r.email);
|
||||
if (!f.ok) { console.warn('prizes: pass check did not answer for', r.who, '- award waits for the next tick'); return null; }
|
||||
}
|
||||
}
|
||||
return awardNow(last, notify);
|
||||
} finally { awarding = false; }
|
||||
}
|
||||
function awardNow(last, notify) {
|
||||
if (store.read('prizes', []).some(x => x.week === last)) return null;
|
||||
const r = awardWeek(last);
|
||||
if (r && r.winners && r.winners.length && notify) notify('prize', r).catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user