fix: distinguish payout and refund terminal states

This commit is contained in:
jwinterm
2026-07-22 13:07:42 -04:00
parent 05aa436ac5
commit b2772ff73b
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ FROM schema_migrations;
WITH audit(category, row_count, atomic_amount) AS (
SELECT 'payout_nonterminal', COUNT(*), COALESCE(SUM(amount), 0)::numeric
FROM payouts
WHERE status IS NULL OR status NOT IN ('recorded', 'completed')
WHERE status IS DISTINCT FROM 'completed'
UNION ALL
SELECT 'payout_completed_missing_tx', COUNT(*), COALESCE(SUM(amount), 0)::numeric
FROM payouts
@@ -71,7 +71,7 @@ WITH ledger AS (
WHERE status = 'completed' AND NULLIF(BTRIM(COALESCE(tx_hash, '')), '') IS NULL
UNION ALL
SELECT COUNT(*) FROM payment_refunds
WHERE status IS DISTINCT FROM 'completed'
WHERE status IS NULL OR status NOT IN ('recorded', 'completed')
UNION ALL
SELECT COUNT(*) FROM games WHERE status IS NULL OR status NOT IN ('won', 'lost', 'expired')
UNION ALL