From 9324868e5ad6264744afd9f5a5ea7555ab2de65b Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Wed, 14 Aug 2024 09:29:35 +0300 Subject: [PATCH] SONAR-22699 Fix measures and leak query cache --- .../js/apps/overview/branches/BranchOverview.tsx | 1 + server/sonar-web/src/main/js/queries/measures.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx index 0c829116996..abe81a18c4f 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx @@ -116,6 +116,7 @@ export default function BranchOverview(props: Readonly) { const { data: measuresAndLeak } = useMeasuresAndLeakQuery({ componentKey: component.key, + branchLike: branch, metricKeys: component.qualifier === ComponentQualifier.Project ? projectQualityGateStatus?.conditions !== undefined diff --git a/server/sonar-web/src/main/js/queries/measures.ts b/server/sonar-web/src/main/js/queries/measures.ts index 90522111df9..2acbbaca5f6 100644 --- a/server/sonar-web/src/main/js/queries/measures.ts +++ b/server/sonar-web/src/main/js/queries/measures.ts @@ -219,15 +219,25 @@ export const useMeasuresAndLeakQuery = createQueryHook( ({ componentKey, metricKeys, + branchLike, branchParameters, }: { + branchLike?: BranchLike; branchParameters?: BranchParameters; componentKey: string; metricKeys: string[]; }) => { const queryClient = useQueryClient(); return queryOptions({ - queryKey: ['measures', 'details', 'component', componentKey, metricKeys, branchParameters], + queryKey: [ + 'measures', + 'details', + 'component', + componentKey, + metricKeys, + branchLike, + branchParameters, + ], queryFn: async () => { // TODO remove this once all metrics are supported const filteredMetricKeys = metricKeys.filter( @@ -242,7 +252,7 @@ export const useMeasuresAndLeakQuery = createQueryHook( metricKeys.forEach((metricKey) => { const measure = measuresMapByMetricKey[metricKey]?.[0] ?? null; queryClient.setQueryData( - ['measures', 'details', componentKey, metricKey], + ['measures', 'details', componentKey, 'branchLike', branchLike, metricKey], measure, ); }); -- 2.39.5