mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
f67341dd70
GetAllTenantIdsAsync answered "which tenants exist?" by scanning the entire Sessions table (PK projection) — an O(corpus) cost paid multiple times per 2h maintenance run by all 6 callers (stalled/excessive sweeps, retention fanout, platform-stats recompute, distress-report cleanup). It grows with session history rather than tenant count. Read the TenantConfiguration table instead (one "config" row per tenant, same proven pattern as TableConfigRepository). Same return shape, so all callers benefit with no interface or DI change. Trade-off (documented in code): a fully-offboarded tenant whose config row was deleted but whose old sessions still linger is no longer visited by maintenance sweeps. Acceptable — the offboarding cascade removes those sessions anyway, and a merely disabled tenant keeps its config row and is still processed. Not bundled here: day-windowing RecomputePlatformStatsAsync — its counters are cumulative/all-time and need separate semantic review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>