Skip to content

Commit c17203f

Browse files
author
Kishore Kumaar Natarajan
committed
Update the logic in QueryInsights Dynamic Columns
Signed-off-by: Kishore Kumaar Natarajan <[email protected]>
1 parent 4c9054f commit c17203f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

public/pages/QueryInsights/QueryInsights.tsx

+18-15
Original file line numberDiff line numberDiff line change
@@ -327,23 +327,26 @@ const QueryInsights = ({
327327
const hasQueryType = selectedFilter.includes('NONE');
328328
const hasGroupType = selectedFilter.includes('SIMILARITY');
329329

330-
if (queries.length === 0) {
331-
if (hasQueryType && hasGroupType) return defaultColumns;
332-
if (hasGroupType) return groupTypeColumns;
333-
if (hasQueryType) return queryTypeColumns;
334-
} else if (queries.every((q) => q.group_by === 'NONE')) {
335-
if (hasQueryType && hasGroupType) return queryTypeColumns;
336-
if (hasQueryType) return queryTypeColumns;
337-
} else if (queries.every((q) => q.group_by === 'SIMILARITY')) {
338-
if (hasQueryType && hasGroupType) return groupTypeColumns;
339-
if (hasGroupType) return groupTypeColumns;
340-
} else {
341-
if (hasQueryType && hasGroupType) return defaultColumns;
342-
if (hasQueryType) return queryTypeColumns.filter((col) => col.name !== 'group');
343-
if (hasGroupType) return groupTypeColumns.filter((col) => col.name !== 'query');
330+
if (hasQueryType && hasGroupType) {
331+
if (queries.length === 0) return defaultColumns;
332+
else {
333+
const containsOnlyQueryType = queries.every((q) => q.group_by === 'NONE');
334+
const containsOnlyGroupType = queries.every((q) => q.group_by === 'SIMILARITY');
335+
336+
if (containsOnlyQueryType) {
337+
return queryTypeColumns;
338+
}
339+
340+
if (containsOnlyGroupType) {
341+
return groupTypeColumns;
342+
}
343+
return defaultColumns;
344+
}
344345
}
346+
if (hasGroupType) return groupTypeColumns;
347+
if (hasQueryType) return queryTypeColumns;
345348

346-
return defaultColumns; // Fallback to default columns
349+
return defaultColumns;
347350
}, [selectedFilter, queries]);
348351

349352
const onChangeFilter = ({ query: searchQuery }) => {

0 commit comments

Comments
 (0)