- 5 tasks: revert vaultLoop to SQL, replace broadcast backfill with
per-entry re-fetch, wire into entry points, delete unused helper
and its test, smoke check
- refetchRunningBalances walks /log pagination and UPDATEs each row
from its own data.balance
- Drops the fetchLiveVaultBalance helper (queried /money which is
total-vault not per-user)
- The previous fix's broadcast backfill was clobbering per-entry
historical balances with a single value
- 4 tasks: failing test, helper implementation, vaultLoop switch, smoke check
- New helper fetchLiveVaultBalance(string $user): ?int in includes/utilities.php
- vaultLoop prefers the live value, falls back to MAX(running_balance)
- Per-request cache to avoid N HTTP calls
- Test hook via $GLOBALS['liveBalanceTestHook'] for unit testing
- Falls back gracefully on API failure
- Compares old (api-sample.json) and new (api-sample-new.json) shapes
- Specifies Authorization: ApiKey header instead of ?key= query param
- Specifies following _metadata.links.next for pagination
- Specifies entry.id (string) as PRIMARY KEY with INSERT ... ON CONFLICT DO NOTHING
- Adds backfillUserLogs (replaces firstRun) and syncUserLogs (renamed from getLog)
- Adds shared fetchAndStoreLogPage helper
- Adds golden-file unit test (no live API)