From e98cfa9d7e4f0c005b356403346c462840c079e0 Mon Sep 17 00:00:00 2001 From: mahmutkaya Date: Mon, 20 Jul 2026 14:34:38 +0200 Subject: [PATCH] perf(fleet): scope /admin/fleet reads to registry tenant slugs (Gemini #71 follow-up) Filter fleetDevice/fleetSummary findMany by the registry's active tenant slugs so orphaned/decommissioned rows aren't loaded as the fleet grows. No-op at the current single-tenant scale; the deferred optimization from the #71 release review. Co-Authored-By: Claude Opus 4.8 --- app/(control)/admin/fleet/page.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/(control)/admin/fleet/page.tsx b/app/(control)/admin/fleet/page.tsx index 288d750..2552953 100644 --- a/app/(control)/admin/fleet/page.tsx +++ b/app/(control)/admin/fleet/page.tsx @@ -139,9 +139,15 @@ export default async function AdminFleetPage() { ); } + // Scope the reads to the tenants we'll actually render (the registry), so orphaned/decommissioned + // rows don't get loaded as the fleet grows (Gemini review on #71). + const tenantSlugs = registry.tenants.map((t) => t.slug); const [devices, summaries] = await Promise.all([ - db.fleetDevice.findMany({ orderBy: [{ tenantSlug: "asc" }, { label: "asc" }] }), - db.fleetSummary.findMany(), + db.fleetDevice.findMany({ + where: { tenantSlug: { in: tenantSlugs } }, + orderBy: [{ tenantSlug: "asc" }, { label: "asc" }], + }), + db.fleetSummary.findMany({ where: { tenantSlug: { in: tenantSlugs } } }), ]); const devicesBySlug = new Map();