From 148925cb95a7507d9c12932cd68a5336b2e971cc Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 4 Feb 2026 17:19:20 +0100 Subject: [PATCH] Fix AI suggestions query running twice Disable automatic refetching for expensive AI assignment query: - Set staleTime to Infinity (never auto-refetch) - Disable refetchOnWindowFocus, refetchOnReconnect, refetchOnMount - Only manual refresh via button will trigger new request Co-Authored-By: Claude Opus 4.5 --- src/app/(admin)/admin/rounds/[id]/assignments/page.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/(admin)/admin/rounds/[id]/assignments/page.tsx b/src/app/(admin)/admin/rounds/[id]/assignments/page.tsx index c8b4794..97b543e 100644 --- a/src/app/(admin)/admin/rounds/[id]/assignments/page.tsx +++ b/src/app/(admin)/admin/rounds/[id]/assignments/page.tsx @@ -89,10 +89,16 @@ function AssignmentManagementContent({ roundId }: { roundId: string }) { { enabled: !!round && !useAI } ) - // AI-powered suggestions + // AI-powered suggestions (expensive - disable auto refetch) const { data: aiSuggestionsRaw, isLoading: loadingAI, refetch: refetchAI } = trpc.assignment.getAISuggestions.useQuery( { roundId, useAI: true }, - { enabled: !!round && useAI } + { + enabled: !!round && useAI, + staleTime: Infinity, // Never consider stale (only refetch manually) + refetchOnWindowFocus: false, + refetchOnReconnect: false, + refetchOnMount: false, + } ) // Normalize AI suggestions to match algorithmic format