diff --git a/lib/rewards.js b/lib/rewards.js index e7f183a..9995214 100644 --- a/lib/rewards.js +++ b/lib/rewards.js @@ -38,11 +38,17 @@ function paidToday(day) { return store.read('payouts', []).filter(p => p.day === day && p.status !== 'failed' && !p.prize).reduce((n, p) => n + p.pol, 0); } -// has this member completed this mission already? -// by member id, and also by wallet: two accounts sharing a wallet get one drip per mission between them +// has this member completed this mission TODAY (Central)? Missions reset at midnight Central with the codes and +// the pool (Marty, 2026-09-20: yesterday's finds showed as done today). Checked by member id, and also by wallet: +// two accounts sharing a wallet get one drip per mission per day between them. function completed(memberId, missionId, wallet) { - const w = wallet ? String(wallet).toLowerCase() : null; - return store.read('payouts', []).some(p => p.missionId === missionId && p.status !== 'failed' && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))); + const w = wallet ? String(wallet).toLowerCase() : null; const day = ctDay(); + return store.read('payouts', []).some(p => p.missionId === missionId && p.day === day && p.status !== 'failed' && !p.prize && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))); +} +// the mission ids this member (or wallet) has done today +function doneToday(memberId, wallet) { + const w = wallet ? String(wallet).toLowerCase() : null; const day = ctDay(); + return new Set(store.read('payouts', []).filter(p => p.day === day && p.status !== 'failed' && !p.prize && (p.memberId === Number(memberId) || (w && p.wallet && String(p.wallet).toLowerCase() === w))).map(p => p.missionId)); } // record a completion; decide paid-today vs queued @@ -96,4 +102,4 @@ function totals() { return { paid: paid.length, pol: Math.round(paid.reduce((n, p) => n + p.pol, 0) * 10000) / 10000, queued: all.filter(p => p.status === 'queued').length, today: paidToday(ctDay()), hunters: new Set(paid.map(p => p.memberId)).size }; } -module.exports = { settings, setSettings, draw, grant, completed, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday }; +module.exports = { settings, setSettings, draw, grant, completed, doneToday, payable, mark, ledger, mine, totals, paidToday, pool, nextResetAt, daily, findsToday }; diff --git a/public/app.html b/public/app.html index bcc1bf1..e164722 100644 --- a/public/app.html +++ b/public/app.html @@ -46,6 +46,6 @@
- +