Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(query assist) enforce timerange to QUERY_ASSIST_START_TIME #1379

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/components/common/search/query_area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
export function QueryArea({
tabId,
handleQueryChange,
handleTimePickerChange,
handleTimeRangePickerRefresh,
runQuery,
tempQuery,
Expand All @@ -21,7 +22,7 @@
nlqInput,
setNlqInput,
pplService,
}: any) {

Check warning on line 25 in public/components/common/search/query_area.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const requestParams = { tabId };
const { getAvailableFields } = useFetchEvents({
pplService,
Expand All @@ -29,8 +30,8 @@
});

// use effect that sets the editor text and populates sidebar field for a particular index upon initialization
const memoizedGetAvailableFields = useMemo(() => getAvailableFields, []);

Check warning on line 33 in public/components/common/search/query_area.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'getAvailableFields'. Either include it or remove the dependency array
const memoizedHandleQueryChange = useMemo(() => handleQueryChange, []);

Check warning on line 34 in public/components/common/search/query_area.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has a missing dependency: 'handleQueryChange'. Either include it or remove the dependency array
useEffect(() => {
const indexQuery = `source = ${selectedIndex[0].label}`;
memoizedHandleQueryChange(indexQuery);
Expand Down Expand Up @@ -66,6 +67,7 @@
<EuiFlexItem>
<QueryAssistInput
tabId={tabId}
handleTimePickerChange={handleTimePickerChange}
handleQueryChange={handleQueryChange}
handleTimeRangePickerRefresh={handleTimeRangePickerRefresh}
setNeedsUpdate={setNeedsUpdate}
Expand Down
1 change: 1 addition & 0 deletions public/components/common/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
tempQuery: string;
handleQueryChange: (query: string) => void;
handleQuerySearch: () => void;
dslService: any;

Check warning on line 73 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface IDatePickerProps {
Expand All @@ -80,12 +80,12 @@
setEndTime: (end: string) => void;
setTimeRange: () => void;
setIsOutputStale: () => void;
handleTimePickerChange: (timeRange: string[]) => any;

Check warning on line 83 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
handleTimeRangePickerRefresh: () => any;

Check warning on line 84 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
isAppAnalytics: boolean;
}

export const Search = (props: any) => {

Check warning on line 88 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const {
query,
tempQuery,
Expand Down Expand Up @@ -153,7 +153,7 @@
error: pollingError,
startPolling: _startPolling,
stopPolling,
} = usePolling<any, any>((params) => {

Check warning on line 156 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 156 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return sqlService.fetchWithJobId(params);
}, 5000);

Expand Down Expand Up @@ -241,7 +241,7 @@
stopPolling();
setIsQueryRunning(false);
}
}, [pollingResult, pollingError]);

Check warning on line 244 in public/components/common/search/search.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'dispatchOnGettingHis', 'setIsQueryRunning', and 'stopPolling'. Either include them or remove the dependency array

useEffect(() => {
// set index and olly query assistant question if changed elsewhere
Expand Down Expand Up @@ -514,6 +514,7 @@
<QueryArea
tabId={tabId}
handleQueryChange={handleQueryChange}
handleTimePickerChange={handleTimePickerChange}
handleTimeRangePickerRefresh={handleTimeRangePickerRefresh}
runQuery={query}
tempQuery={tempQuery}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { RAW_QUERY } from '../../../../../common/constants/explorer';
import { QUERY_ASSIST_API } from '../../../../../common/constants/query_assist';
import { QUERY_ASSIST_START_TIME } from '../../../../../common/constants/shared';
import { getOSDHttp } from '../../../../../common/utils';
import { coreRefs } from '../../../../framework/core_refs';
import chatLogo from '../../../datasources/icons/query-assistant-logo.svg';
Expand All @@ -47,6 +48,7 @@ interface SummarizationContext {
interface Props {
handleQueryChange: (query: string) => void;
handleTimeRangePickerRefresh: (availability?: boolean, setSummaryStatus?: boolean) => void;
handleTimePickerChange: (timeRange: string[]) => Promise<void>;
tabId: string;
setNeedsUpdate: any;
selectedIndex: Array<EuiComboBoxOptionOption<string | number | string[] | undefined>>;
Expand Down Expand Up @@ -246,6 +248,7 @@ export const QueryAssistInput: React.FC<Props> = (props) => {
try {
setGeneratingOrRunning(true);
await request();
await props.handleTimePickerChange([QUERY_ASSIST_START_TIME, 'now']);
await props.handleTimeRangePickerRefresh(undefined, true);
} catch (error) {
generateSummary({ isError: true, response: JSON.stringify((error as ResponseError).body) });
Expand Down
Loading