Skip to content

Commit 2b5ca44

Browse files
useAutoCompleteOptions: use current search dateRange.
1 parent ecb0f2c commit 2b5ca44

File tree

9 files changed

+38
-16
lines changed

9 files changed

+38
-16
lines changed

packages/app/src/DBSearchPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ function DBSearchPage() {
12951295
placeholder="Search your events w/ Lucene ex. column:foo"
12961296
queryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_LUCENE}
12971297
enableHotkey
1298+
dateRange={searchedTimeRange}
1299+
source={inputSourceObj}
12981300
/>
12991301
}
13001302
/>

packages/app/src/SearchInputV2.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export default function SearchInputV2({
3535
onSubmit,
3636
additionalSuggestions,
3737
queryHistoryType,
38+
dateRange,
39+
source,
3840
...props
3941
}: {
4042
tableConnections?: TableConnection | TableConnection[];
@@ -47,6 +49,8 @@ export default function SearchInputV2({
4749
onSubmit?: () => void;
4850
additionalSuggestions?: string[];
4951
queryHistoryType?: string;
52+
dateRange?: [Date, Date];
53+
source?: any;
5054
} & UseControllerProps<any>) {
5155
const {
5256
field: { onChange, value },
@@ -61,6 +65,8 @@ export default function SearchInputV2({
6165
{
6266
tableConnections,
6367
additionalSuggestions,
68+
dateRange,
69+
source,
6470
},
6571
);
6672

packages/app/src/ServicesDashboardPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ function ServicesDashboardPage() {
944944
language="lucene"
945945
placeholder="Search your events w/ Lucene ex. column:foo"
946946
enableHotkey
947+
dateRange={searchedTimeRange}
948+
source={source}
947949
/>
948950
}
949951
/>

packages/app/src/SessionSubpanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ export default function SessionSubpanel({
505505
size="xs"
506506
placeholder="Search your events w/ Lucene ex. column:foo"
507507
enableHotkey
508+
dateRange={[start, end]}
509+
traceSource={traceSource}
508510
/>
509511
)}
510512
</form>

packages/app/src/SessionsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ export default function SessionsPage() {
472472
language="lucene"
473473
placeholder="Search your events w/ Lucene ex. column:foo"
474474
enableHotkey
475+
dateRange={searchedTimeRange}
476+
source={traceTrace}
475477
/>
476478
}
477479
/>

packages/app/src/components/ContextSidePanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ export default function ContextSubpanel({
214214
placeholder="Lucene where clause (ex. column:value)"
215215
enableHotkey
216216
size="sm"
217+
dateRange={newDateRange}
218+
source={source}
217219
/>
218220
)
219221
}

packages/app/src/components/DBEditTimeChartForm.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ function ChartSeriesEditorComponent({
255255
placeholder="Search your events w/ Lucene ex. column:foo"
256256
onSubmit={onSubmit}
257257
additionalSuggestions={attributeKeys}
258+
dateRange={dateRange}
258259
/>
259260
)}
260261
{showGroupBy && (
@@ -745,6 +746,8 @@ export default function EditTimeChartForm({
745746
language="lucene"
746747
placeholder="Search your events w/ Lucene ex. column:foo"
747748
onSubmit={onSubmit}
749+
dateRange={dateRange}
750+
source={tableSource}
748751
/>
749752
)}
750753
</Flex>

packages/app/src/components/KubernetesFilters.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ export const KubernetesFilters: React.FC<KubernetesFiltersProps> = ({
239239
control={control}
240240
size="xs"
241241
enableHotkey
242+
dateRange={dateRange}
243+
source={metricSource}
242244
/>
243245
</Group>
244246
);

packages/app/src/hooks/useAutoCompleteOptions.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ export function useAutoCompleteOptions(
2121
{
2222
tableConnections,
2323
additionalSuggestions,
24+
dateRange,
25+
source,
2426
}: {
2527
tableConnections?: TableConnection | TableConnection[];
2628
additionalSuggestions?: string[];
29+
dateRange?: [Date, Date];
30+
source?: any; // TSource 类型,外部传入
2731
},
2832
) {
2933
// Fetch and gather all field options
@@ -87,22 +91,19 @@ export function useAutoCompleteOptions(
8791
// hooks to get key values
8892
const chartConfigs: ChartConfigWithDateRange[] = toArray(
8993
tableConnections,
90-
).map(({ databaseName, tableName, connectionId }) => ({
91-
connection: connectionId,
92-
from: {
93-
databaseName,
94-
tableName,
95-
},
96-
timestampValueExpression: '',
97-
select: '',
98-
where: '',
99-
// TODO: Pull in date for query as arg
100-
// just assuming 1/2 day is okay to query over right now
101-
dateRange: [
102-
new Date(Date.now() - (86400 * 1000) / 2),
103-
new Date(Date.now()),
104-
],
105-
}));
94+
).map(({ databaseName, tableName, connectionId }) => {
95+
return {
96+
connection: connectionId,
97+
from: {
98+
databaseName,
99+
tableName,
100+
},
101+
timestampValueExpression: source?.timestampValueExpression,
102+
select: '',
103+
where: '',
104+
dateRange: dateRange,
105+
};
106+
});
106107
const { data: keyVals } = useGetKeyValues({
107108
chartConfigs,
108109
keys: searchKeys,

0 commit comments

Comments
 (0)