Module supabase/functions/sgtm_usage_aggregate_daily

Fileoverview

SGTM Usage Aggregate Daily Edge Function

Scheduled cron job that aggregates access log metrics into daily usage records. Runs once per day to process the previous day's data.

Endpoint

POST /sgtm_usage_aggregate_daily

Auth

None - Typically called by cron scheduler

Remarks

  • Aggregates "yesterday" in UTC timezone
  • Calls the sgtm_usage_aggregate_daily_window RPC function
  • Creates/updates records in sgtm_usage_daily table
  • Used for billing calculations and analytics dashboards

Tables touched:

  • sgtm_access_logs (read via RPC)
  • sgtm_usage_daily (write via RPC)

Returns

200 - "OK" on success

Returns

500 - "Error" on RPC failure