diff --git a/packages/api/src/controllers/queryHistory.js b/packages/api/src/controllers/queryHistory.js index c2ed112bf..0cbb75e88 100644 --- a/packages/api/src/controllers/queryHistory.js +++ b/packages/api/src/controllers/queryHistory.js @@ -14,7 +14,7 @@ function readCore(reader, skip, limit, filter) { if (!line && !line.trim()) return; try { const json = JSON.parse(line); - if (filterName(filter, json.sql)) { + if (filterName(filter, json.sql, json.database)) { if (!skip || readed >= skip) { res.push(json); } diff --git a/packages/tools/src/filterName.ts b/packages/tools/src/filterName.ts index 95867d507..fd43404db 100644 --- a/packages/tools/src/filterName.ts +++ b/packages/tools/src/filterName.ts @@ -39,6 +39,12 @@ export function filterName(filter: string, ...names: string[]) { // const camelVariants = [name.replace(/[^A-Z]/g, '')] const tokens = filter.split(' ').map(x => x.trim()); - return !!_compact(names).find(name => !tokens.find(token => !name.toUpperCase().includes(token.toUpperCase()))); - // return name.toUpperCase().includes(filter.toUpperCase()); + const namesCompacted = _compact(names); + for (const token of tokens) { + const tokenUpper = token.toUpperCase(); + const found = namesCompacted.find(name => name.toUpperCase().includes(tokenUpper)); + if (!found) return false; + } + + return true; } diff --git a/packages/web/src/widgets/QueryHistoryList.svelte b/packages/web/src/widgets/QueryHistoryList.svelte index 9eba88ae3..398fda4d4 100644 --- a/packages/web/src/widgets/QueryHistoryList.svelte +++ b/packages/web/src/widgets/QueryHistoryList.svelte @@ -9,6 +9,7 @@ import { onMount } from 'svelte'; import socket from '../utility/socket'; import axiosInstance from '../utility/axiosInstance'; + import openNewTab from '../utility/openNewTab'; let filter = ''; let search = ''; @@ -50,7 +51,24 @@ {#each historyItems as item} -
+
{ + openNewTab( + { + title: 'Query #', + icon: 'icon sql-file', + tabComponent: 'QueryTab', + props: { + conid: item.conid, + database: item.database, + }, + }, + { editor: item.sql } + ); + }} + >
{item.sql}