mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
fix(insights): count failed fetches toward a bounded poll's ceiling
The status and advisor polls counted attempts on dataUpdateCount, which a failed fetch does not move, while the last good payload stayed in place and still said preparing. A request that kept failing polled an open page for as long as it stayed open. Attempts now include the failed fetches. The poll inventory moves from a comment into a guard held to every refetchInterval in the tree; four polls were missing from the comment.
This commit is contained in:
1 parent
b12bece491
commit
985372f711
7 files changed
+282
-48
No files matched your search
@@ -4,6 +4,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { useAiCapability } from "@/hooks/use-ai-capability";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { pollAttemptCount } from "@/lib/queries/refetch-interval";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import type { MetricStatusMetricId } from "@/lib/insights/metric-status-registry";
|
||||
import type { AssessmentStatus } from "@/lib/insights/status-shared";
|
||||
@@ -221,9 +222,8 @@ async function fetchStatusData(
|
||||
|
||||
function useStatusPollAttemptCount(queryKey: readonly unknown[]): number {
|
||||
const queryClient = useQueryClient();
|
||||
return (
|
||||
queryClient.getQueryState<InsightStatusData>(queryKey)?.dataUpdateCount ?? 0
|
||||
);
|
||||
const state = queryClient.getQueryState<InsightStatusData>(queryKey);
|
||||
return state ? pollAttemptCount(state) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ export function useInsightStatus(metric: InsightStatusMetric) {
|
||||
refetchInterval: (query) =>
|
||||
nextStatusPollInterval(
|
||||
query.state.data?.preparing,
|
||||
query.state.dataUpdateCount,
|
||||
pollAttemptCount(query.state),
|
||||
query.state.data?.revalidating,
|
||||
),
|
||||
});
|
||||
@@ -383,7 +383,7 @@ export function useInsightMetricStatus(
|
||||
refetchInterval: (query) =>
|
||||
nextStatusPollInterval(
|
||||
query.state.data?.preparing,
|
||||
query.state.dataUpdateCount,
|
||||
pollAttemptCount(query.state),
|
||||
query.state.data?.revalidating,
|
||||
),
|
||||
});
|
||||
@@ -438,7 +438,7 @@ export function useInsightBiomarkerAssessment(
|
||||
refetchInterval: (query) =>
|
||||
nextStatusPollInterval(
|
||||
query.state.data?.preparing,
|
||||
query.state.dataUpdateCount,
|
||||
pollAttemptCount(query.state),
|
||||
query.state.data?.revalidating,
|
||||
),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user