Skip to content

useAutoCompleteOptions: use current search dateRange. #975

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,8 @@ function DBSearchPage() {
placeholder="Search your events w/ Lucene ex. column:foo"
queryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_LUCENE}
enableHotkey
dateRange={searchedTimeRange}
source={inputSourceObj}
/>
}
/>
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/SearchInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export default function SearchInputV2({
onSubmit,
additionalSuggestions,
queryHistoryType,
dateRange,
source,
...props
}: {
tableConnections?: TableConnection | TableConnection[];
Expand All @@ -47,6 +49,8 @@ export default function SearchInputV2({
onSubmit?: () => void;
additionalSuggestions?: string[];
queryHistoryType?: string;
dateRange?: [Date, Date];
source?: any;
} & UseControllerProps<any>) {
const {
field: { onChange, value },
Expand All @@ -61,6 +65,8 @@ export default function SearchInputV2({
{
tableConnections,
additionalSuggestions,
dateRange,
source,
},
);

Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/ServicesDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ function ServicesDashboardPage() {
language="lucene"
placeholder="Search your events w/ Lucene ex. column:foo"
enableHotkey
dateRange={searchedTimeRange}
source={source}
/>
}
/>
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/SessionSubpanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ export default function SessionSubpanel({
size="xs"
placeholder="Search your events w/ Lucene ex. column:foo"
enableHotkey
dateRange={[start, end]}
traceSource={traceSource}
/>
)}
</form>
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/SessionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ export default function SessionsPage() {
language="lucene"
placeholder="Search your events w/ Lucene ex. column:foo"
enableHotkey
dateRange={searchedTimeRange}
source={traceTrace}
/>
}
/>
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/components/ContextSidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export default function ContextSubpanel({
placeholder="Lucene where clause (ex. column:value)"
enableHotkey
size="sm"
dateRange={newDateRange}
source={source}
/>
)
}
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/components/DBEditTimeChartForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ function ChartSeriesEditorComponent({
placeholder="Search your events w/ Lucene ex. column:foo"
onSubmit={onSubmit}
additionalSuggestions={attributeKeys}
dateRange={dateRange}
source={tableSource}
/>
)}
{showGroupBy && (
Expand Down Expand Up @@ -745,6 +747,8 @@ export default function EditTimeChartForm({
language="lucene"
placeholder="Search your events w/ Lucene ex. column:foo"
onSubmit={onSubmit}
dateRange={dateRange}
source={tableSource}
/>
)}
</Flex>
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/components/KubernetesFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ export const KubernetesFilters: React.FC<KubernetesFiltersProps> = ({
control={control}
size="xs"
enableHotkey
dateRange={dateRange}
source={metricSource}
/>
</Group>
);
Expand Down
33 changes: 17 additions & 16 deletions packages/app/src/hooks/useAutoCompleteOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export function useAutoCompleteOptions(
{
tableConnections,
additionalSuggestions,
dateRange,
source,
}: {
tableConnections?: TableConnection | TableConnection[];
additionalSuggestions?: string[];
dateRange?: [Date, Date];
source?: any; // TSource 类型,外部传入
},
) {
// Fetch and gather all field options
Expand Down Expand Up @@ -87,22 +91,19 @@ export function useAutoCompleteOptions(
// hooks to get key values
const chartConfigs: ChartConfigWithDateRange[] = toArray(
tableConnections,
).map(({ databaseName, tableName, connectionId }) => ({
connection: connectionId,
from: {
databaseName,
tableName,
},
timestampValueExpression: '',
select: '',
where: '',
// TODO: Pull in date for query as arg
// just assuming 1/2 day is okay to query over right now
dateRange: [
new Date(Date.now() - (86400 * 1000) / 2),
new Date(Date.now()),
],
}));
).map(({ databaseName, tableName, connectionId }) => {
return {
connection: connectionId,
from: {
databaseName,
tableName,
},
timestampValueExpression: source?.timestampValueExpression,
select: '',
where: '',
dateRange: dateRange,
};
});
const { data: keyVals } = useGetKeyValues({
chartConfigs,
keys: searchKeys,
Expand Down