]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22699 Fix measures and leak query cache
authorIsmail Cherri <ismail.cherri@sonarsource.com>
Wed, 14 Aug 2024 06:29:35 +0000 (09:29 +0300)
committersonartech <sonartech@sonarsource.com>
Mon, 26 Aug 2024 20:03:06 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx
server/sonar-web/src/main/js/queries/measures.ts

index 0c829116996021f628dbd7a0d1fe9ecc68377454..abe81a18c4f28ed359ae0542c113875d0846623b 100644 (file)
@@ -116,6 +116,7 @@ export default function BranchOverview(props: Readonly<Props>) {
 
   const { data: measuresAndLeak } = useMeasuresAndLeakQuery({
     componentKey: component.key,
+    branchLike: branch,
     metricKeys:
       component.qualifier === ComponentQualifier.Project
         ? projectQualityGateStatus?.conditions !== undefined
index 90522111df977ece4415f211b62361bae0e3f8ab..2acbbaca5f65620c0790d609524bf097e476acf7 100644 (file)
@@ -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<Measure>(
-            ['measures', 'details', componentKey, metricKey],
+            ['measures', 'details', componentKey, 'branchLike', branchLike, metricKey],
             measure,
           );
         });