digital-identity-platform-docs
digital-identity-platform-docs / supabase/functions/backfill-recovered-hits
supabase/functions/backfill-recovered-hits
Backfill job that re-processes historical access logs to update recovery flags and re-aggregate daily usage data.
Overview
This Edge Function corrects historical data after fixes to the Router Worker recovery detection logic. It updates is_recovered flags in access logs and re-aggregates daily usage statistics for the specified number of past days.
Endpoint
POST /functions/v1/backfill-recovered-hits
Authentication
Requires x-cron-secret header matching the CRON_SECRET environment variable.
Behavior
- Validates cron secret for authorization
- Calls
backfill_recovered_flagsRPC to updateis_recoveredflags - Iterates through each day and calls
sgtm_usage_aggregate_daily_windowRPC - Returns summary of successful and failed day aggregations
Tables Touched
sgtm_access_logs(write via RPC)sgtm_usage_daily(write via RPC)
Notes
- Idempotent - safe to run multiple times
- Processes day-by-day to avoid timeouts
- Default is 30 days, configurable via
days_backbody parameter