Skip to content

Commit

Permalink
fixing session id stuff and running async queries
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <[email protected]>
  • Loading branch information
sejli authored and kavilla committed Aug 1, 2024
1 parent 55ec24f commit ffcfd8a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 0 additions & 3 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ export {
// for BWC, keeping the old name
IUiStart as DataPublicPluginStartUi,
DataSetNavigator,
setAsyncSessionId,
getAsyncSessionId,
setAsyncSessionIdByObj,
} from './ui';

/**
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/ui/dataset_navigator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@

export { DataSetNavigator, DataSetNavigatorProps } from './dataset_navigator';
export { createDataSetNavigator } from './create_dataset_navigator';
export { setAsyncSessionId, getAsyncSessionId, setAsyncSessionIdByObj } from './lib';
7 changes: 1 addition & 6 deletions src/plugins/data/public/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,4 @@ export {
} from './query_editor';
export { SearchBar, SearchBarProps, StatefulSearchBarProps } from './search_bar';
export { SuggestionsComponent } from './typeahead';
export {
DataSetNavigator,
setAsyncSessionId,
getAsyncSessionId,
setAsyncSessionIdByObj,
} from './dataset_navigator';
export { DataSetNavigator } from './dataset_navigator';
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
ISearchOptions,
SearchInterceptor,
SearchInterceptorDeps,
getAsyncSessionId,
setAsyncSessionId,
} from '../../../data/public';
import {
API,
Expand All @@ -36,13 +34,15 @@ import { QueryEnhancementsPluginStartDependencies } from '../types';
export class SQLSearchInterceptor extends SearchInterceptor {
protected queryService!: DataPublicPluginStart['query'];
protected aggsService!: DataPublicPluginStart['search']['aggs'];
protected uiService!: DataPublicPluginStart['ui'];

constructor(deps: SearchInterceptorDeps) {
super(deps);

deps.startServices.then(([coreStart, depsStart]) => {
this.queryService = (depsStart as QueryEnhancementsPluginStartDependencies).data.query;
this.aggsService = (depsStart as QueryEnhancementsPluginStartDependencies).data.search.aggs;
this.uiService = (depsStart as QueryEnhancementsPluginStartDependencies).data.ui;
});
}

Expand Down Expand Up @@ -122,7 +122,9 @@ export class SQLSearchInterceptor extends SearchInterceptor {
...dataFrame.meta.queryConfig,
...dataSourceRef,
},
sessionId: dataSourceRef ? getAsyncSessionId(dataSourceRef.dataSourceName!) : {},
sessionId: dataSourceRef
? this.uiService.Settings.getUserQuerySessionId(dataSourceRef.dataSourceName!)
: {},
};

const onPollingSuccess = (pollingResult: any) => {
Expand Down Expand Up @@ -162,7 +164,10 @@ export class SQLSearchInterceptor extends SearchInterceptor {
concatMap((jobResponse) => {
const df = jobResponse.body;
if (dataSourceRef?.dataSourceName && df?.meta?.sessionId) {
setAsyncSessionId(dataSourceRef.dataSourceName, df?.meta?.sessionId);
this.uiService.Settings.setUserQuerySessionId(
dataSourceRef.dataSourceName,
df?.meta?.sessionId
);
}
const dataFramePolling = new DataFramePolling<any, any>(
() => fetchDataFramePolling(dfContext, df),
Expand Down

0 comments on commit ffcfd8a

Please sign in to comment.