From 4a4ea9fcb1d2da7afca46cd85babe02c915e1ebf Mon Sep 17 00:00:00 2001 From: Sai Nikhil Date: Mon, 22 Sep 2025 14:26:04 +0530 Subject: [PATCH] fix: should add include search term before group by clause (#8515) ### **User description** This PR fixes the #8510 ___ ### **PR Type** Bug fix ___ ### **Description** - Insert filters before GROUP BY clause - Handle both include and exclude terms - Preserve ORDER BY and LIMIT positions - Align query splitting via group-by branch ___ ### Diagram Walkthrough ```mermaid flowchart LR Query["Incoming query"] --> CheckOB["Has ORDER BY?"] CheckOB -- Yes --> InsertBeforeOB["Insert filter before ORDER BY"] CheckOB -- No --> CheckGB["Has GROUP BY?"] CheckGB -- Yes --> InsertBeforeGB["Insert filter before GROUP BY"] CheckGB -- No --> CheckLimit["Has LIMIT?"] CheckLimit -- Yes --> InsertBeforeLimit["Insert filter before LIMIT"] CheckLimit -- No --> AppendFilter["Append filter at end/with WHERE"] ```

File Walkthrough

Relevant files
Bug fix
SearchBar.vue
Add group-by-aware filter insertion logic                               

web/src/plugins/logs/SearchBar.vue
  • Add GROUP BY branch when adding filters.
  • Insert "AND"/"where" filter before GROUP BY.
  • Maintain existing ORDER BY and LIMIT handling.
  • Minor formatting of conditional branches.
+26/-2   
___ --- web/src/plugins/logs/SearchBar.vue | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/web/src/plugins/logs/SearchBar.vue b/web/src/plugins/logs/SearchBar.vue index 3ac1fd5050..c91b6f200e 100644 --- a/web/src/plugins/logs/SearchBar.vue +++ b/web/src/plugins/logs/SearchBar.vue @@ -4097,7 +4097,19 @@ export default defineComponent({ filter + " order by" + afterOrderBy; - } else if (query.toLowerCase().includes("limit")) { + } else if (query.toLowerCase().includes("group by")) { + const [beforeGroupBy, afterGroupBy] = queryIndexSplit( + query, + "group by", + ); + query = + beforeGroupBy.trim() + + " AND " + + filter + + " group by" + + afterGroupBy; + } + else if (query.toLowerCase().includes("limit")) { const [beforeLimit, afterLimit] = queryIndexSplit( query, "limit", @@ -4123,7 +4135,19 @@ export default defineComponent({ filter + " order by" + afterOrderBy; - } else if (query.toLowerCase().includes("limit")) { + } else if (query.toLowerCase().includes("group by")) { + const [beforeGroupBy, afterGroupBy] = queryIndexSplit( + query, + "group by", + ); + query = + beforeGroupBy.trim() + + " where " + + filter + + " group by" + + afterGroupBy; + } + else if (query.toLowerCase().includes("limit")) { const [beforeLimit, afterLimit] = queryIndexSplit( query, "limit",