Skip to content

Commit 61afdb4

Browse files
committed
feat: Implement query chunking for charts
1 parent 0cf179f commit 61afdb4

File tree

12 files changed

+1277
-135
lines changed

12 files changed

+1277
-135
lines changed

.changeset/soft-donkeys-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
feat: Implement query chunking for charts

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@mantine/spotlight": "7.9.2",
4242
"@microsoft/fetch-event-source": "^2.0.1",
4343
"@tabler/icons-react": "^3.5.0",
44-
"@tanstack/react-query": "^5.56.2",
44+
"@tanstack/react-query": "^5.90.2",
4545
"@tanstack/react-query-devtools": "^5.56.2",
4646
"@tanstack/react-table": "^8.7.9",
4747
"@tanstack/react-virtual": "^3.0.1",

packages/app/src/components/DBTimeChart.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function DBTimeChartComponent({
6262
limit: { limit: 100000 },
6363
};
6464

65-
const { data, isLoading, isError, error, isPlaceholderData, isSuccess } =
65+
const { data, isLoading, isError, error, isSuccess, isFetching } =
6666
useQueriedChartConfig(queriedConfig, {
6767
placeholderData: (prev: any) => prev,
6868
queryKey: [queryKeyPrefix, queriedConfig],
@@ -75,7 +75,6 @@ function DBTimeChartComponent({
7575
}
7676
}, [isError, isErrorExpanded, errorExpansion]);
7777

78-
const isLoadingOrPlaceholder = isLoading || isPlaceholderData;
7978
const { data: source } = useSource({ id: sourceId });
8079

8180
const { graphResults, timestampColumn, groupKeys, lineNames, lineColors } =
@@ -338,7 +337,7 @@ function DBTimeChartComponent({
338337
graphResults={graphResults}
339338
groupKeys={groupKeys}
340339
isClickActive={false}
341-
isLoading={isLoadingOrPlaceholder}
340+
isLoading={isFetching}
342341
lineColors={lineColors}
343342
lineNames={lineNames}
344343
logReferenceTimestamp={logReferenceTimestamp}

packages/app/src/components/PatternTable.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export default function PatternTable({
2929

3030
const [selectedPattern, setSelectedPattern] = useState<Pattern | null>(null);
3131

32-
const { totalCount, isLoading: isTotalCountLoading } = useSearchTotalCount(
33-
totalCountConfig,
34-
totalCountQueryKeyPrefix,
35-
);
32+
const {
33+
totalCount,
34+
isLoading: isTotalCountLoading,
35+
isTotalCountComplete,
36+
} = useSearchTotalCount(totalCountConfig, totalCountQueryKeyPrefix);
3637

3738
const {
3839
data: groupedResults,
@@ -46,7 +47,8 @@ export default function PatternTable({
4647
totalCount,
4748
});
4849

49-
const isLoading = isTotalCountLoading || isGroupedPatternsLoading;
50+
const isLoading =
51+
isTotalCountLoading || !isTotalCountComplete || isGroupedPatternsLoading;
5052

5153
const sortedGroupedResults = useMemo(() => {
5254
return Object.values(groupedResults).sort(

packages/app/src/components/SearchTotalCountChart.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export function useSearchTotalCount(
2828
placeholderData: keepPreviousData, // no need to flash loading state when in live tail
2929
});
3030

31+
const isTotalCountComplete = !!totalCountData?.isComplete;
32+
3133
const totalCount = useMemo(() => {
3234
return totalCountData?.data?.reduce(
3335
(p: number, v: any) => p + Number.parseInt(v['count()']),
@@ -39,6 +41,7 @@ export function useSearchTotalCount(
3941
totalCount,
4042
isLoading,
4143
isError,
44+
isTotalCountComplete,
4245
};
4346
}
4447

0 commit comments

Comments
 (0)