Skip to content

Conversation

@ktx-vaidehi
Copy link
Collaborator

@ktx-vaidehi ktx-vaidehi commented Oct 16, 2025

PR Type

Enhancement


Description

  • Add value mapping cache for fast lookups

  • Avoid deep clone; use original data

  • Precompute config and timezone for formatters

  • Case-insensitive field lookup caching


Diagram Walkthrough

flowchart LR
  BuildCache["Build value-mapping cache"] -- "used by" --> Lookup["Fast lookupValueMapping"]
  Overrides["Process override configs"] -- "populate" --> ColorUnitMaps["colorConfigMap/unitConfigMap (lowercased)"]
  Rows["Use original searchQueryData rows"] -- "avoid deep clone" --> Convert["convertTableData pipeline"]
  FieldsCache["Cache field names (lowercased)"] -- "resolve aliases" --> Columns["Build columns"]
  Timezone["Cache timezone from store"] -- "used by" --> DateFmt["Date formatting for histograms"]
  Convert -- "format numbers/dates" --> Columns
  Lookup -- "value mapping" --> Columns
Loading

File Walkthrough

Relevant files
Enhancement
convertTableData.ts
Performance-focused refactor of table conversion logic     

web/src/utils/dashboard/convertTableData.ts

  • Add cached value mapping builder and lookup
  • Use shallow data, cache field names and timezone
  • Lowercase keys for color/unit config maps
  • Precompute unit/decimals for numeric formatting
+126/-74

@ktx-vaidehi ktx-vaidehi changed the title feat: optimize value mapping with caching for improved performance refactor: optimize value mapping with caching for improved performance Oct 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2025

PR Reviewer Guide 🔍

(Review updated until commit 468f653)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The variable actualField is referenced when building column definitions, but it is not defined in the new code after switching to fieldNameCache; this will cause a runtime ReferenceError and break table rendering.

obj["name"] = it.label;
obj["field"] = actualField;
obj["label"] = it.label;
obj["align"] = !isNumber ? "left" : "right";
obj["sortable"] = true;
Range Mapping Logic

Range lookups iterate all cache entries and parse keys with a string prefix; this is O(n) per lookup and fragile to float string formatting and inclusive bounds; verify correctness and performance on large mapping sets and consider a dedicated structure for ranges.

// Check range mappings
if (typeof value === 'number') {
  const entries = Array.from(cache.entries());
  for (let i = 0; i < entries.length; i++) {
    const [key, text] = entries[i];
    if (typeof key === 'string' && key.startsWith('__range_')) {
      const parts = key.split('_');
      const from = parseFloat(parts[2]);
      const to = parseFloat(parts[3]);
      if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
        return text;
      }
    }
  }
}

return null;
Shallow Copy Risk

Replacing deep clone of searchQueryData[0] with a shallow reference may allow downstream mutations of tableRows to mutate original data; confirm immutability assumptions or enforce non-mutating operations.

// Avoid deep cloning - use shallow copy and work with original data
let tableRows = searchQueryData[0];
const histogramFields: string[] = [];

// Build value mapping cache once for all cells

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2025

PR Code Suggestions ✨

Latest suggestions up to 468f653
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent unintended data mutation

Mutating tableRows will now mutate searchQueryData[0] since it's a direct reference,
potentially corrupting shared state across renders. Restore immutability by creating
a shallow copy of the rows array and its objects before modifying.

web/src/utils/dashboard/convertTableData.ts [116-118]

-// Avoid deep cloning - use shallow copy and work with original data
-let tableRows = searchQueryData[0];
+// Create a shallow copy to avoid mutating original data
+let tableRows = Array.isArray(searchQueryData[0])
+  ? searchQueryData[0].map((row: any) => ({ ...row }))
+  : [];
Suggestion importance[1-10]: 8

__

Why: The PR changed to reference searchQueryData[0] directly, risking unintended mutation of shared state; creating a shallow copy prevents side effects and aligns with previous behavior without deep cloning.

Medium
Normalize mapping keys

Using numeric keys directly in Map risks mismatches when inputs are strings (e.g.,
"1" vs 1). Normalize direct mapping keys to strings and explicitly mark them to
avoid collisions with range keys.

web/src/utils/dashboard/convertTableData.ts [28-49]

 const buildValueMappingCache = (mappings: any) => {
   if (!mappings || !Array.isArray(mappings)) {
     return null;
   }
 
-  const cache = new Map<any, string>();
+  const cache = new Map<string, string>();
 
   mappings.forEach((mapping: any) => {
     if (mapping && mapping.text) {
-      // Handle range mappings
       if (mapping.from !== undefined && mapping.to !== undefined) {
-        // Store range info for later lookup
         cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
       } else if (mapping.value !== undefined && mapping.value !== null) {
-        // Direct value mapping
-        cache.set(mapping.value, mapping.text);
+        cache.set(`__value_${String(mapping.value)}`, mapping.text);
       }
     }
   });
 
   return cache.size > 0 ? cache : null;
 };
Suggestion importance[1-10]: 6

__

Why: Normalizing keys to strings and prefixing avoids "1" vs 1 mismatches and collisions with range keys, improving correctness; however, it requires coordinated changes with the lookup to be fully effective.

Low
General
Fix lookup correctness and cost

The direct lookup can miss string-number equivalence and scanning the entire map for
ranges is O(n). Align with the normalized keys and short-circuit by checking a
prefixed key; also attempt numeric coercion for range evaluation when value is a
numeric string.

web/src/utils/dashboard/convertTableData.ts [64-89]

-const lookupValueMapping = (value: any, cache: Map<any, string> | null) => {
+const lookupValueMapping = (value: any, cache: Map<string, string> | null) => {
   if (!cache) return null;
 
-  // Direct lookup first
-  if (cache.has(value)) {
-    return cache.get(value);
+  // Direct lookup using normalized key
+  const directKey = `__value_${String(value)}`;
+  if (cache.has(directKey)) {
+    return cache.get(directKey) as string;
   }
 
-  // Check range mappings
-  if (typeof value === 'number') {
-    const entries = Array.from(cache.entries());
-    for (let i = 0; i < entries.length; i++) {
-      const [key, text] = entries[i];
-      if (typeof key === 'string' && key.startsWith('__range_')) {
+  // Attempt numeric range check if value can be treated as number
+  const num = typeof value === 'number' ? value : (typeof value === 'string' ? Number(value) : NaN);
+  if (!Number.isNaN(num)) {
+    for (const [key, text] of cache.entries()) {
+      if (key.startsWith('__range_')) {
         const parts = key.split('_');
         const from = parseFloat(parts[2]);
         const to = parseFloat(parts[3]);
-        if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
+        if (!isNaN(from) && !isNaN(to) && num >= from && num <= to) {
           return text;
         }
       }
     }
   }
 
   return null;
 };
Suggestion importance[1-10]: 6

__

Why: Adapting lookup to normalized keys and coercing numeric strings improves hit rate and avoids type pitfalls, but the range scan remains O(n) and also depends on adopting the normalized cache structure.

Low

Previous suggestions

Suggestions up to commit f4eaf91
CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent unintended data mutation

Mutating tableRows now directly mutates searchQueryData[0], which can introduce
hard-to-track side effects across the app. If downstream logic modifies rows
(sorting, formatting, etc.), keep immutability by shallow-cloning the array and its
objects where needed.

web/src/utils/dashboard/convertTableData.ts [116-118]

-// Avoid deep cloning - use shallow copy and work with original data
-let tableRows = searchQueryData[0];
+// Use a shallow clone of the rows to avoid mutating original data
+let tableRows = Array.isArray(searchQueryData[0])
+  ? searchQueryData[0].map((r: any) => ({ ...r }))
+  : [];
Suggestion importance[1-10]: 7

__

Why: Changing from deep clone to direct reference can introduce side effects; shallow-cloning rows is a reasonable mitigation with low cost and preserves immutability, though impact depends on later mutations in this function.

Medium
Harden alias case-insensitive lookups

fieldNameCache is built from the first row’s keys; if later rows contain different
casing or missing keys, lookups may fail. Guard against absent or non-string
it.alias before .toLowerCase() and fall back safely if fieldNameCache lacks the key
to avoid runtime errors.

web/src/utils/dashboard/convertTableData.ts [236-248]

-const aliasLower = it.alias.toLowerCase();
-const actualField = fieldNameCache[aliasLower] || it.alias;
+const aliasKey = typeof it.alias === 'string' ? it.alias.toLowerCase() : '';
+const actualField = aliasKey && fieldNameCache[aliasKey] ? fieldNameCache[aliasKey] : it.alias;
 ...
-if (colorConfigMap?.[aliasLower]?.autoColor) {
+if (aliasKey && colorConfigMap?.[aliasKey]?.autoColor) {
   obj["colorMode"] = "auto";
 }
 ...
 let unitToUse = null;
 let customUnitToUse = null;
-if (unitConfigMap[aliasLower]) {
-  unitToUse = unitConfigMap[aliasLower].unit;
-  customUnitToUse = unitConfigMap[aliasLower].customUnit;
+if (aliasKey && unitConfigMap[aliasKey]) {
+  unitToUse = unitConfigMap[aliasKey].unit;
+  customUnitToUse = unitConfigMap[aliasKey].customUnit;
 }
Suggestion importance[1-10]: 5

__

Why: Guarding .toLowerCase() against non-string aliases and missing cache entries prevents potential runtime errors; beneficial but relatively minor given typical alias types.

Low
General
Use structured range caching

Encoding ranges into string keys and then iterating all entries for lookup is
error-prone and O(n) per lookup. Store range mappings in a separate array and check
those after a direct map hit to avoid key parsing bugs and improve clarity and
performance.

web/src/utils/dashboard/convertTableData.ts [28-49]

 const buildValueMappingCache = (mappings: any) => {
   if (!mappings || !Array.isArray(mappings)) {
     return null;
   }
 
-  const cache = new Map<any, string>();
+  const direct = new Map<any, string>();
+  const ranges: Array<{ from: number; to: number; text: string }> = [];
 
   mappings.forEach((mapping: any) => {
     if (mapping && mapping.text) {
-      // Handle range mappings
       if (mapping.from !== undefined && mapping.to !== undefined) {
-        // Store range info for later lookup
-        cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
+        const fromNum = Number(mapping.from);
+        const toNum = Number(mapping.to);
+        if (!Number.isNaN(fromNum) && !Number.isNaN(toNum)) {
+          ranges.push({ from: fromNum, to: toNum, text: mapping.text });
+        }
       } else if (mapping.value !== undefined && mapping.value !== null) {
-        // Direct value mapping
-        cache.set(mapping.value, mapping.text);
+        direct.set(mapping.value, mapping.text);
       }
     }
   });
 
-  return cache.size > 0 ? cache : null;
+  return direct.size > 0 || ranges.length > 0 ? { direct, ranges } : null;
 };
 
+const lookupValueMapping = (value: any, cache: { direct: Map<any, string>; ranges: Array<{ from: number; to: number; text: string }> } | null) => {
+  if (!cache) return null;
+  const hit = cache.direct.get(value);
+  if (hit !== undefined) return hit;
+
+  if (typeof value === 'number') {
+    for (let i = 0; i < cache.ranges.length; i++) {
+      const r = cache.ranges[i];
+      if (value >= r.from && value <= r.to) {
+        return r.text;
+      }
+    }
+  }
+  return null;
+};
+
Suggestion importance[1-10]: 6

__

Why: The proposal correctly identifies the string-encoded range keys and O(n) lookup, offering a clearer cache structure and lookup; it's an improvement but not critical to correctness.

Low

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: refactor/dashboard-table-chart-logic | Commit: f4eaf91

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 364 342 0 19 3 94% 7m 6s

View Detailed Results

@ktx-vaidehi ktx-vaidehi force-pushed the refactor/dashboard-table-chart-logic branch from f4eaf91 to 468f653 Compare October 17, 2025 11:02
@ktx-vaidehi ktx-vaidehi marked this pull request as ready for review October 17, 2025 11:02
@github-actions
Copy link
Contributor

Persistent review updated to latest commit 468f653

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

Optimized table data conversion by caching value mappings, unit/color configs, and timezone lookups. Removed deep cloning to work with original data directly.

Critical Issues Found:

  • Missing regex mapping support: Cache only handles value and range types, omitting regex pattern matching entirely (lines 28-49, 64-89)
  • Incorrect lowercase transformation: aliasLower = alias should be alias.toLowerCase() for proper case-insensitive lookup (line 135)
  • Data mutation risk: Shallow copy instead of deep clone means mutations to tableRows affect original searchQueryData[0] (line 117)

Performance Improvements:

  • Pre-built value mapping cache reduces O(n×m) to O(1) or O(log n) lookups
  • Config maps avoid repeated override config traversals
  • Cached timezone/decimals eliminate repeated store/config reads
  • Field name cache speeds up case-insensitive field resolution

Confidence Score: 2/5

  • Not safe to merge - contains critical bugs that break existing functionality
  • Three critical bugs found: (1) regex mapping support completely removed causing feature regression, (2) incorrect variable assignment breaks case-insensitive lookups, (3) shallow copy introduces potential data mutation. These will cause runtime failures for dashboards using regex mappings and case-sensitive field mismatches.
  • web/src/utils/dashboard/convertTableData.ts requires immediate attention to fix regex mapping support, lowercase transformation, and shallow copy issues

Important Files Changed

File Analysis

Filename Score Overview
web/src/utils/dashboard/convertTableData.ts 2/5 Performance optimizations introduced three critical bugs: missing regex mapping support, incorrect lowercase transformation, and potential data mutation from shallow copy

Sequence Diagram

sequenceDiagram
    participant Caller
    participant convertTableData
    participant buildCache as buildValueMappingCache
    participant lookup as lookupValueMapping
    participant formatter as Column Formatters

    Caller->>convertTableData: panelSchema, searchQueryData
    
    Note over convertTableData: Shallow copy (no deep clone)
    convertTableData->>convertTableData: tableRows = searchQueryData[0]
    
    convertTableData->>buildCache: panelSchema.config.mappings
    Note over buildCache: Build once for all cells
    buildCache->>buildCache: Create Map cache for value/range
    Note right of buildCache: ❌ Missing regex mappings
    buildCache-->>convertTableData: valueMappingCache
    
    Note over convertTableData: Build config maps once
    convertTableData->>convertTableData: Build colorConfigMap
    convertTableData->>convertTableData: Build unitConfigMap
    Note right of convertTableData: ❌ aliasLower = alias (not lowercased)
    convertTableData->>convertTableData: Build fieldNameCache
    
    loop For each column
        convertTableData->>formatter: Create format function
        Note over formatter: Closure captures:<br/>- valueMappingCache<br/>- unitConfigMap<br/>- timezone (cached)<br/>- decimals (cached)
        
        formatter->>lookup: value, valueMappingCache
        lookup->>lookup: Check direct value in Map
        lookup->>lookup: Check range mappings
        Note right of lookup: ❌ No regex check
        lookup-->>formatter: mapped value or null
    end
    
    convertTableData-->>Caller: {rows, columns}
Loading

1 file reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +28 to +49
const buildValueMappingCache = (mappings: any) => {
if (!mappings || !Array.isArray(mappings)) {
return null;
}

const cache = new Map<any, string>();

mappings.forEach((mapping: any) => {
if (mapping && mapping.text) {
// Handle range mappings
if (mapping.from !== undefined && mapping.to !== undefined) {
// Store range info for later lookup
cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
} else if (mapping.value !== undefined && mapping.value !== null) {
// Direct value mapping
cache.set(mapping.value, mapping.text);
}
}
});

return cache.size > 0 ? cache : null;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Cache doesn't handle all mapping types - regex type mappings are missing

The original findFirstValidMappedValue function supports three mapping types: value, range, and regex. The new cache only handles direct value and range mappings, but completely omits regex pattern matching.

Suggested change
const buildValueMappingCache = (mappings: any) => {
if (!mappings || !Array.isArray(mappings)) {
return null;
}
const cache = new Map<any, string>();
mappings.forEach((mapping: any) => {
if (mapping && mapping.text) {
// Handle range mappings
if (mapping.from !== undefined && mapping.to !== undefined) {
// Store range info for later lookup
cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
} else if (mapping.value !== undefined && mapping.value !== null) {
// Direct value mapping
cache.set(mapping.value, mapping.text);
}
}
});
return cache.size > 0 ? cache : null;
};
const buildValueMappingCache = (mappings: any) => {
if (!mappings || !Array.isArray(mappings)) {
return null;
}
const cache = new Map<any, string>();
const regexMappings: Array<{pattern: RegExp, text: string}> = [];
mappings.forEach((mapping: any) => {
if (mapping && mapping.text) {
// Handle regex mappings separately
if (mapping.type === "regex" && mapping.pattern) {
regexMappings.push({ pattern: new RegExp(mapping.pattern), text: mapping.text });
}
// Handle range mappings
else if ((mapping.type === "range" || mapping.from !== undefined) && mapping.to !== undefined) {
// Store range info for later lookup
cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
} else if ((mapping.type === "value" || mapping.value !== undefined) && mapping.value !== null) {
// Direct value mapping
cache.set(mapping.value, mapping.text);
}
}
});
if (cache.size === 0 && regexMappings.length === 0) return null;
return { cache, regexMappings };
};
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/utils/dashboard/convertTableData.ts
Line: 28:49

Comment:
**logic:** Cache doesn't handle all mapping types - `regex` type mappings are missing

The original `findFirstValidMappedValue` function supports three mapping types: `value`, `range`, and `regex`. The new cache only handles direct value and range mappings, but completely omits regex pattern matching.

```suggestion
const buildValueMappingCache = (mappings: any) => {
  if (!mappings || !Array.isArray(mappings)) {
    return null;
  }

  const cache = new Map<any, string>();
  const regexMappings: Array<{pattern: RegExp, text: string}> = [];

  mappings.forEach((mapping: any) => {
    if (mapping && mapping.text) {
      // Handle regex mappings separately
      if (mapping.type === "regex" && mapping.pattern) {
        regexMappings.push({ pattern: new RegExp(mapping.pattern), text: mapping.text });
      }
      // Handle range mappings
      else if ((mapping.type === "range" || mapping.from !== undefined) && mapping.to !== undefined) {
        // Store range info for later lookup
        cache.set(`__range_${mapping.from}_${mapping.to}`, mapping.text);
      } else if ((mapping.type === "value" || mapping.value !== undefined) && mapping.value !== null) {
        // Direct value mapping
        cache.set(mapping.value, mapping.text);
      }
    }
  });

  if (cache.size === 0 && regexMappings.length === 0) return null;
  
  return { cache, regexMappings };
};
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +64 to +89
const lookupValueMapping = (value: any, cache: Map<any, string> | null) => {
if (!cache) return null;

// Direct lookup first
if (cache.has(value)) {
return cache.get(value);
}

// Check range mappings
if (typeof value === 'number') {
const entries = Array.from(cache.entries());
for (let i = 0; i < entries.length; i++) {
const [key, text] = entries[i];
if (typeof key === 'string' && key.startsWith('__range_')) {
const parts = key.split('_');
const from = parseFloat(parts[2]);
const to = parseFloat(parts[3]);
if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
return text;
}
}
}
}

return null;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Lookup function needs to support regex mappings and check explicit types

Update to handle regex mappings and properly check type field:

Suggested change
const lookupValueMapping = (value: any, cache: Map<any, string> | null) => {
if (!cache) return null;
// Direct lookup first
if (cache.has(value)) {
return cache.get(value);
}
// Check range mappings
if (typeof value === 'number') {
const entries = Array.from(cache.entries());
for (let i = 0; i < entries.length; i++) {
const [key, text] = entries[i];
if (typeof key === 'string' && key.startsWith('__range_')) {
const parts = key.split('_');
const from = parseFloat(parts[2]);
const to = parseFloat(parts[3]);
if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
return text;
}
}
}
}
return null;
};
const lookupValueMapping = (value: any, cacheObj: {cache: Map<any, string>, regexMappings: Array<{pattern: RegExp, text: string}>} | null) => {
if (!cacheObj) return null;
const { cache, regexMappings } = cacheObj;
// Direct lookup first
if (cache.has(value)) {
return cache.get(value);
}
// Check range mappings
if (typeof value === 'number') {
const entries = Array.from(cache.entries());
for (let i = 0; i < entries.length; i++) {
const [key, text] = entries[i];
if (typeof key === 'string' && key.startsWith('__range_')) {
const parts = key.split('_');
const from = parseFloat(parts[2]);
const to = parseFloat(parts[3]);
if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
return text;
}
}
}
}
// Check regex mappings
for (const {pattern, text} of regexMappings) {
if (pattern.test(value)) {
return text;
}
}
return null;
};
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/utils/dashboard/convertTableData.ts
Line: 64:89

Comment:
**logic:** Lookup function needs to support regex mappings and check explicit types

Update to handle regex mappings and properly check `type` field:

```suggestion
const lookupValueMapping = (value: any, cacheObj: {cache: Map<any, string>, regexMappings: Array<{pattern: RegExp, text: string}>} | null) => {
  if (!cacheObj) return null;
  
  const { cache, regexMappings } = cacheObj;

  // Direct lookup first
  if (cache.has(value)) {
    return cache.get(value);
  }

  // Check range mappings
  if (typeof value === 'number') {
    const entries = Array.from(cache.entries());
    for (let i = 0; i < entries.length; i++) {
      const [key, text] = entries[i];
      if (typeof key === 'string' && key.startsWith('__range_')) {
        const parts = key.split('_');
        const from = parseFloat(parts[2]);
        const to = parseFloat(parts[3]);
        if (!isNaN(from) && !isNaN(to) && value >= from && value <= to) {
          return text;
        }
      }
    }
  }
  
  // Check regex mappings
  for (const {pattern, text} of regexMappings) {
    if (pattern.test(value)) {
      return text;
    }
  }

  return null;
};
```

How can I resolve this? If you propose a fix, please make it concise.

const config = o?.config?.[0];

if (alias && config) {
const aliasLower = alias;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Variable assigned but never transformed - should be alias.toLowerCase()

Suggested change
const aliasLower = alias;
const aliasLower = alias.toLowerCase();
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/utils/dashboard/convertTableData.ts
Line: 135:135

Comment:
**logic:** Variable assigned but never transformed - should be `alias.toLowerCase()`

```suggestion
        const aliasLower = alias.toLowerCase();
```

How can I resolve this? If you propose a fix, please make it concise.

let columnData = [...x, ...y];
let tableRows = JSON.parse(JSON.stringify(searchQueryData[0]));
// Avoid deep cloning - use shallow copy and work with original data
let tableRows = searchQueryData[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Shallow copy breaks mutability assumptions - can cause unintended side effects

Removing the deep clone means the original searchQueryData[0] is now directly referenced and could be mutated by downstream code. If any code modifies tableRows, it will affect the original data structure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/utils/dashboard/convertTableData.ts
Line: 117:117

Comment:
**logic:** Shallow copy breaks mutability assumptions - can cause unintended side effects

Removing the deep clone means the original `searchQueryData[0]` is now directly referenced and could be mutated by downstream code. If any code modifies `tableRows`, it will affect the original data structure.

How can I resolve this? If you propose a fix, please make it concise.

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: refactor/dashboard-table-chart-logic | Commit: 468f653

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 364 342 0 19 3 94% 7m 7s

View Detailed Results

@ktx-vaidehi ktx-vaidehi force-pushed the refactor/dashboard-table-chart-logic branch from 468f653 to 18a4a09 Compare October 17, 2025 11:39
@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: ktx-vaidehi | Branch: refactor/dashboard-table-chart-logic | Commit: 18a4a09

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 364 342 0 19 3 94% 4m 39s

View Detailed Results

@ktx-vaidehi ktx-vaidehi force-pushed the refactor/dashboard-table-chart-logic branch 2 times, most recently from 464f610 to 2c9931a Compare October 27, 2025 12:21
@ktx-vaidehi ktx-vaidehi force-pushed the refactor/dashboard-table-chart-logic branch from 2c9931a to ace4d9f Compare October 27, 2025 12:58
@ktx-vaidehi ktx-vaidehi merged commit 3dd5e64 into main Oct 27, 2025
31 of 32 checks passed
@ktx-vaidehi ktx-vaidehi deleted the refactor/dashboard-table-chart-logic branch October 27, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants