mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
* fix(usage): reset logs and show provider names in analytics * refactor(db): extract usage purge routines to cleanup module (file-size cap) Move the generic delete-all/delete-before-cutoff table helpers and the call-log-artifact purge helpers out of cleanup.ts into a new cleanup/usagePurge.ts submodule, so this PR's growth in cleanup.ts stays under the file-size gate cap once combined with other in-flight changes to the same file. Pure extraction — resetUsageHistory delegates to the same logic, now imported instead of inlined; no behavior change. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * refactor(db): hoist reset targets table + derive total via reduce (max-lines-per-function) Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * refactor(api): move analytics provider-name enrichment into lib (file-size cap) src/app/api/usage/analytics/route.ts is a frozen file-size-capped file (baseline: 942 lines, zero headroom on this branch). The provider display-name enrichment added for the byProvider breakdown (id -> name/ prefix lookup via provider_nodes) pushed it to 971 lines, tripping the check:file-size ratchet. Move the new getProviderDisplayName/getProviderDisplayNames helpers, plus the byProvider row-building they modified, into a new leaf module src/lib/usage/providerDisplayNames.ts (buildByProviderRows). The route now just imports and calls it. No behavior change: same lookup, same fallback to the raw provider id, same row shape. Net effect: route.ts drops from 941 (pre-change) to 930 lines (-11), comfortably restoring headroom instead of exceeding the frozen cap. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * fix(usage): fall back to static catalog name in provider display resolution Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>