diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts index 8a2cc5d2072c..ef420ab3e130 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts @@ -61,28 +61,27 @@ export const selectApps = createSelector(sqlStatsSelector, sqlStatsState => { } let sawBlank = false; - let sawInternal = false; const apps: { [app: string]: boolean } = {}; sqlStatsState.data.statements.forEach( (statement: ICollectedStatementStatistics) => { - if ( + const isNotInternalApp = sqlStatsState.data.internal_app_name_prefix && - statement.key.key_data.app.startsWith( + !statement.key.key_data.app.startsWith( sqlStatsState.data.internal_app_name_prefix, - ) + ); + if ( + sqlStatsState.data.internal_app_name_prefix == undefined || + isNotInternalApp ) { - sawInternal = true; - } else if (statement.key.key_data.app) { - apps[statement.key.key_data.app] = true; - } else { - sawBlank = true; + if (statement.key.key_data.app) { + apps[statement.key.key_data.app] = true; + } else { + sawBlank = true; + } } }, ); - return [] - .concat(sawInternal ? [sqlStatsState.data.internal_app_name_prefix] : []) - .concat(sawBlank ? ["(unset)"] : []) - .concat(Object.keys(apps)); + return [].concat(sawBlank ? ["(unset)"] : []).concat(Object.keys(apps)); }); // selectDatabases returns the array of all databases with statement statistics present diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts index d4322707afdd..ab5ee29a4bc5 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts @@ -39,14 +39,13 @@ export const getTrxAppFilterOptions = ( transactions: Transaction[], prefix: string, ): string[] => { - const defaultAppFilters = [prefix]; const uniqueAppNames = new Set( transactions .filter(t => !t.stats_data.app.startsWith(prefix)) .map(t => (t.stats_data.app ? t.stats_data.app : "(unset)")), ); - return defaultAppFilters.concat(Array.from(uniqueAppNames)); + return Array.from(uniqueAppNames); }; export const collectStatementsText = (statements: Statement[]): string => diff --git a/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx b/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx index ac5f618b9750..30fd923f432e 100644 --- a/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx +++ b/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx @@ -161,28 +161,27 @@ export const selectApps = createSelector( } let sawBlank = false; - let sawInternal = false; const apps: { [app: string]: boolean } = {}; state.data.statements.forEach( (statement: ICollectedStatementStatistics) => { - if ( + const isNotInternalApp = state.data.internal_app_name_prefix && - statement.key.key_data.app.startsWith( + !statement.key.key_data.app.startsWith( state.data.internal_app_name_prefix, - ) + ); + if ( + state.data.internal_app_name_prefix == undefined || + isNotInternalApp ) { - sawInternal = true; - } else if (statement.key.key_data.app) { - apps[statement.key.key_data.app] = true; - } else { - sawBlank = true; + if (statement.key.key_data.app) { + apps[statement.key.key_data.app] = true; + } else { + sawBlank = true; + } } }, ); - return [] - .concat(sawInternal ? [state.data.internal_app_name_prefix] : []) - .concat(sawBlank ? ["(unset)"] : []) - .concat(Object.keys(apps)); + return [].concat(sawBlank ? ["(unset)"] : []).concat(Object.keys(apps)); }, );