Skip to content

Commit e6a514a

Browse files
committed
fix: rm some changes
1 parent 6bf5727 commit e6a514a

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

src/store/reducers/query/query.ts

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type {StreamingChunk} from '../../../types/store/streaming';
88
import {QUERIES_HISTORY_KEY} from '../../../utils/constants';
99
import {isQueryErrorResponse} from '../../../utils/query';
1010
import {isNumeric} from '../../../utils/utils';
11-
import type {RootState} from '../../defaultStore';
1211
import {api} from '../api';
1312

1413
import {prepareQueryData} from './prepareQueryData';
@@ -188,6 +187,21 @@ const slice = createSlice({
188187
}
189188
},
190189
},
190+
selectors: {
191+
selectQueriesHistoryFilter: (state) => state.history.filter || '',
192+
selectTenantPath: (state) => state.tenantPath,
193+
selectResult: (state) => state.result,
194+
selectQueriesHistory: (state) => {
195+
const items = state.history.queries;
196+
const filter = state.history.filter?.toLowerCase();
197+
198+
return filter
199+
? items.filter((item) => item.queryText.toLowerCase().includes(filter))
200+
: items;
201+
},
202+
selectUserInput: (state) => state.input,
203+
selectQueriesHistoryCurrentIndex: (state) => state.history?.currentIndex,
204+
},
191205
});
192206

193207
export default slice.reducer;
@@ -205,13 +219,24 @@ export const {
205219
addStreamingChunk,
206220
} = slice.actions;
207221

208-
export const selectUserInput = (state: RootState) => state.query.input;
209-
export const selectResult = (state: RootState) => state.query.result;
210-
export const selectTenantPath = (state: RootState) => state.query.tenantPath;
211-
export const selectQueriesHistory = (state: RootState) => state.query.history.queries;
212-
export const selectQueriesHistoryCurrentIndex = (state: RootState) =>
213-
state.query.history.currentIndex;
214-
export const selectQueriesHistoryFilter = (state: RootState) => state.query.history.filter;
222+
export const {
223+
selectQueriesHistoryFilter,
224+
selectQueriesHistoryCurrentIndex,
225+
selectQueriesHistory,
226+
selectTenantPath,
227+
selectResult,
228+
selectUserInput,
229+
} = slice.selectors;
230+
231+
interface SendQueryParams extends QueryRequestParams {
232+
actionType?: QueryAction;
233+
queryId: string;
234+
querySettings?: Partial<QuerySettings>;
235+
// flag whether to send new tracing header or not
236+
// default: not send
237+
enableTracingLevel?: boolean;
238+
isStreaming?: boolean;
239+
}
215240

216241
interface QueryStats {
217242
durationUs?: string | number;
@@ -361,11 +386,3 @@ export const queryApi = api.injectEndpoints({
361386
}),
362387
overrideExisting: 'throw',
363388
});
364-
365-
interface SendQueryParams extends QueryRequestParams {
366-
actionType?: QueryAction;
367-
queryId: string;
368-
querySettings?: Partial<QuerySettings>;
369-
enableTracingLevel?: boolean;
370-
isStreaming?: boolean;
371-
}

0 commit comments

Comments
 (0)