Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Sep 4, 2024
1 parent d752f25 commit 430b2a7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';

import './_recent_query.scss';
import { EuiButtonEmpty, EuiPopover, EuiText, EuiPopoverTitle } from '@elastic/eui';

Expand All @@ -25,7 +27,7 @@ export interface QueryStatus {
};
statusCode?: number;
};
time?: number;
elapsedMs?: number;
}

export function QueryResult(props: { queryStatus: QueryStatus }) {
Expand All @@ -38,7 +40,9 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
return (

Check warning on line 40 in src/plugins/data/public/query/query_string/language_service/lib/query_result.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/language_service/lib/query_result.tsx#L40

Added line #L40 was not covered by tests
<EuiButtonEmpty iconSide="left" iconType={'checkInCircleEmpty'} size="xs" onClick={() => {}}>
<EuiText size="xs" color="subdued">
{props.queryStatus.time ? `Completed in ${props.queryStatus.time} ms` : 'Completed'}
{props.queryStatus.elapsedMs
? `Completed in ${props.queryStatus.elapsedMs} ms`
: 'Completed'}
</EuiText>
</EuiButtonEmpty>
);
Expand All @@ -65,12 +69,21 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
<EuiPopoverTitle>ERRORS</EuiPopoverTitle>
<div style={{ width: '250px' }}>
<EuiText size="s">
<strong>Reasons: </strong>
<strong>
{i18n.translate('data.query.languageService.queryResults.reasons', {
defaultMessage: `Reasons:`,
})}
</strong>
{props.queryStatus.body.error.reason}
</EuiText>
<EuiText size="s">
<p>
<strong>Details:</strong> {props.queryStatus.body.error.details}
<strong>
{i18n.translate('data.query.languageService.queryResults.details', {
defaultMessage: `Details:`,
})}
</strong>{' '}
{props.queryStatus.body.error.details}
</p>
</EuiText>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ export interface IUiStart {
IndexPatternSelect: React.ComponentType<IndexPatternSelectProps>;
SearchBar: React.ComponentType<StatefulSearchBarProps>;
SuggestionsComponent: React.ComponentType<SuggestionsComponentProps>;
setQueryStatus: (status: QueryStatus) => void;
}
6 changes: 0 additions & 6 deletions src/plugins/data/public/ui/ui_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface UiServiceStartDependencies {

export class UiService implements Plugin<IUiSetup, IUiStart> {
enhancementsConfig: ConfigSchema['enhancements'];
private queryStatus$ = new BehaviorSubject<QueryStatus>({ status: ResultStatus.READY });

constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
const { enhancements } = initializerContext.config.get<ConfigSchema>();
Expand All @@ -40,10 +39,6 @@ export class UiService implements Plugin<IUiSetup, IUiStart> {
}

public start(core: CoreStart, { dataServices, storage }: UiServiceStartDependencies): IUiStart {
const setQueryStatus = (status: QueryStatus) => {
this.queryStatus$.next(status);
};

const SearchBar = createSearchBar({
core,
data: dataServices,
Expand All @@ -54,7 +49,6 @@ export class UiService implements Plugin<IUiSetup, IUiStart> {
IndexPatternSelect: createIndexPatternSelect(core.savedObjects.client),
SearchBar,
SuggestionsComponent,
setQueryStatus,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface SearchData {
};
statusCode?: number;
};
time?: number;
elapsedMs?: number;
};
}

Expand Down Expand Up @@ -160,7 +160,7 @@ export const useSearch = (services: DiscoverViewServices) => {

dataset = searchSource.getField('index');

let queryTime;
let elapsedMs;

try {
// Only show loading indicator if we are fetching when the rows are empty
Expand Down Expand Up @@ -193,7 +193,7 @@ export const useSearch = (services: DiscoverViewServices) => {
.ok({ json: fetchResp });
const hits = fetchResp.hits.total as number;
const rows = fetchResp.hits.hits;
queryTime = inspectorRequest.getTime();
elapsedMs = inspectorRequest.getTime();

Check warning on line 196 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/discover/public/application/view_components/utils/use_search.ts#L196

Added line #L196 was not covered by tests
let bucketInterval = {};
let chartData;
for (const row of rows) {
Expand Down Expand Up @@ -231,7 +231,7 @@ export const useSearch = (services: DiscoverViewServices) => {
? searchSource.getDataFrame()?.name
: indexPattern?.title,
queryStatus: {
time: queryTime,
elapsedMs,
},
});
} catch (error) {
Expand Down Expand Up @@ -259,7 +259,7 @@ export const useSearch = (services: DiscoverViewServices) => {
status: ResultStatus.ERROR,
queryStatus: {
body: errorBody,
time: queryTime,
elapsedMs,
},
});
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const pplSearchStrategyProvider = (
took: rawResponse.took,
} as IDataFrameResponse;
} catch (e) {
logger.error(`pplSearchStrategy: ${e}`);
logger.error(`pplSearchStrategy: ${e.message}`);
if (usage) usage.trackError();
throw e;
}
Expand Down

0 comments on commit 430b2a7

Please sign in to comment.