Skip to content

Commit

Permalink
pass in query time
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Aug 30, 2024
1 parent 7547e10 commit 726c11c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function QueryResult(props: { queryResult: SearchData }) {
return (
<EuiButtonEmpty iconSide="left" iconType={'checkInCircleEmpty'} size="xs" onClick={() => {}}>
<EuiText size="xs" color="subdued">
{'Complete'}
{'Complete in ' + props.queryResult.queryTime + ' ms'}
</EuiText>
</EuiButtonEmpty>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR
{fetchState.status === ResultStatus.NO_RESULTS && (
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} />
)}
{fetchState.status === ResultStatus.ERROR && (
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} />
)}
{fetchState.status === ResultStatus.UNINITIALIZED && (
<DiscoverUninitialized onRefresh={() => refetch$.next()} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface SearchData {
chartData?: Chart;
title?: string;
errorMsg?: any;
queryTime?: number;
}

export type SearchRefetch = 'refetch' | undefined;
Expand Down Expand Up @@ -151,6 +152,8 @@ export const useSearch = (services: DiscoverViewServices) => {

dataset = searchSource.getField('index');

let queryTime;

try {
// Only show loading indicator if we are fetching when the rows are empty
if (fetchStateRef.current.rows?.length === 0) {
Expand Down Expand Up @@ -182,6 +185,9 @@ export const useSearch = (services: DiscoverViewServices) => {
.ok({ json: fetchResp });
const hits = fetchResp.hits.total as number;
const rows = fetchResp.hits.hits;
//setQueryTime(inspectorRequest.getTime());

Check failure on line 188 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Expected exception block, space or tab after '//' in comment
//console.log('queryTime', queryTime);

Check failure on line 189 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Expected exception block, space or tab after '//' in comment
queryTime = inspectorRequest.getTime();
let bucketInterval = {};
let chartData;
for (const row of rows) {
Expand Down Expand Up @@ -218,6 +224,7 @@ export const useSearch = (services: DiscoverViewServices) => {
indexPattern?.title !== searchSource.getDataFrame()?.name
? searchSource.getDataFrame()?.name
: indexPattern?.title,
queryTime,
});
} catch (error) {
// If the request was aborted then no need to surface this error in the UI
Expand All @@ -230,6 +237,7 @@ export const useSearch = (services: DiscoverViewServices) => {
indexPattern?.title !== searchSource.getDataFrame()?.name
? searchSource.getDataFrame()?.name
: indexPattern?.title,
queryTime,
});

console.log('error', error.body);

Check failure on line 243 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View workflow job for this annotation

GitHub Actions / Build and Verify on Linux (ciGroup1)

Unexpected console statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ export class RequestResponder {
public error(response: Response): void {
this.finish(RequestStatus.ERROR, response);
}

public getTime() {
return this.request.time;
}
}

0 comments on commit 726c11c

Please sign in to comment.