S8 (a1): ops — the product watches itself
Settlement alarm (settle-pass THROW pages high; morning zero-settle alarm keyed off the Postgres ledger settle results, once per ET date, never on an empty yesterday), per-sport 3-consecutive-slot failure pager (pure opsWatch.createFailureTracker, pages once per losing streak), odds-api >=80% quota alert (once per day, Redis-deduped), systemHealth (statfs + os mem, disk>85 / mem>90 pages), daily 9 AM ET pulse (ONE notification: ledger rows yesterday via ledgerService.countRowsForDate, settles 24h, quota, disk/mem, desk line), docs/OPS-RUNBOOK.md (Uptime Kuma monitors, Coolify deploy-failure -> ntfy, phone subscription). All copy VOICE v1.1 — deadpan, numbers, no exclamation points (tests lint for it). 2398 -> 2437 tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -361,6 +361,27 @@ async function defaultGetPlayerStats(name, sport) {
|
||||
return { found: false }; // no free settled-result feed yet → pending
|
||||
}
|
||||
|
||||
/**
|
||||
* Session 8 (A1 board, ops) — count of ledger rows for one game_date (the
|
||||
* daily pulse's "rows written yesterday"). Returns null (NOT 0) when Supabase
|
||||
* isn't configured or the count fails — the pulse renders "n/a", never a
|
||||
* fabricated zero.
|
||||
*/
|
||||
async function countRowsForDate(gameDate, opts = {}) {
|
||||
if (!gameDate) return null;
|
||||
if (!opts.sb && !isConfigured()) return null;
|
||||
try {
|
||||
const sb = opts.sb || defaultClient();
|
||||
const { count, error } = await sb.from('ledger_entries')
|
||||
.select('id', { count: 'exact', head: true })
|
||||
.eq('game_date', gameDate);
|
||||
if (error) return null;
|
||||
return count || 0;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 30-day aggregate over the PUBLIC model record (user_id NULL): hit rate,
|
||||
* beat-the-close rate, pending count. Percentages are null below
|
||||
@@ -453,6 +474,7 @@ module.exports = {
|
||||
settleLedger,
|
||||
settleAllLedgers,
|
||||
applyRevision,
|
||||
countRowsForDate,
|
||||
getModelAggregate,
|
||||
MIN_AGG_SAMPLE,
|
||||
__internals: {
|
||||
|
||||
Reference in New Issue
Block a user