|
5 | 5 | * |
6 | 6 | * Copyright Oxide Computer Company |
7 | 7 | */ |
| 8 | +import { useQuery } from '@tanstack/react-query' |
8 | 9 | import { useMemo, useRef } from 'react' |
9 | 10 |
|
10 | | -import { |
11 | | - synthesizeData, |
12 | | - useApiQuery, |
13 | | - type ChartDatum, |
14 | | - type SystemMetricName, |
15 | | -} from '@oxide/api' |
| 11 | +import { apiq, synthesizeData, type ChartDatum, type SystemMetricName } from '@oxide/api' |
16 | 12 |
|
17 | 13 | import { ChartContainer, ChartHeader, TimeSeriesChart } from './TimeSeriesChart' |
18 | 14 |
|
@@ -53,23 +49,21 @@ export function SiloMetric({ |
53 | 49 | }: SiloMetricProps) { |
54 | 50 | // TODO: we're only pulling the first page. Should we bump the cap to 10k? |
55 | 51 | // Fetch multiple pages if 10k is not enough? That's a bit much. |
56 | | - const inRange = useApiQuery( |
57 | | - 'siloMetric', |
58 | | - { |
59 | | - path: { metricName }, |
60 | | - query: { project, startTime, endTime, limit: 3000 }, |
61 | | - }, |
62 | | - { placeholderData: (x) => x } |
| 52 | + const inRange = useQuery( |
| 53 | + apiq( |
| 54 | + 'siloMetric', |
| 55 | + { path: { metricName }, query: { project, startTime, endTime, limit: 3000 } }, |
| 56 | + { placeholderData: (x) => x } |
| 57 | + ) |
63 | 58 | ) |
64 | 59 |
|
65 | 60 | // get last point before startTime to use as first point in graph |
66 | | - const beforeStart = useApiQuery( |
67 | | - 'siloMetric', |
68 | | - { |
69 | | - path: { metricName }, |
70 | | - query: { project, endTime: startTime, ...staticParams }, |
71 | | - }, |
72 | | - { placeholderData: (x) => x } |
| 61 | + const beforeStart = useQuery( |
| 62 | + apiq( |
| 63 | + 'siloMetric', |
| 64 | + { path: { metricName }, query: { project, endTime: startTime, ...staticParams } }, |
| 65 | + { placeholderData: (x) => x } |
| 66 | + ) |
73 | 67 | ) |
74 | 68 |
|
75 | 69 | const ref = useRef<ChartDatum[] | undefined>(undefined) |
@@ -124,23 +118,21 @@ export function SystemMetric({ |
124 | 118 | }: SystemMetricProps) { |
125 | 119 | // TODO: we're only pulling the first page. Should we bump the cap to 10k? |
126 | 120 | // Fetch multiple pages if 10k is not enough? That's a bit much. |
127 | | - const inRange = useApiQuery( |
128 | | - 'systemMetric', |
129 | | - { |
130 | | - path: { metricName }, |
131 | | - query: { silo, startTime, endTime, limit: 3000 }, |
132 | | - }, |
133 | | - { placeholderData: (x) => x } |
| 121 | + const inRange = useQuery( |
| 122 | + apiq( |
| 123 | + 'systemMetric', |
| 124 | + { path: { metricName }, query: { silo, startTime, endTime, limit: 3000 } }, |
| 125 | + { placeholderData: (x) => x } |
| 126 | + ) |
134 | 127 | ) |
135 | 128 |
|
136 | 129 | // get last point before startTime to use as first point in graph |
137 | | - const beforeStart = useApiQuery( |
138 | | - 'systemMetric', |
139 | | - { |
140 | | - path: { metricName }, |
141 | | - query: { silo, endTime: startTime, ...staticParams }, |
142 | | - }, |
143 | | - { placeholderData: (x) => x } |
| 130 | + const beforeStart = useQuery( |
| 131 | + apiq( |
| 132 | + 'systemMetric', |
| 133 | + { path: { metricName }, query: { silo, endTime: startTime, ...staticParams } }, |
| 134 | + { placeholderData: (x) => x } |
| 135 | + ) |
144 | 136 | ) |
145 | 137 |
|
146 | 138 | const ref = useRef<ChartDatum[] | undefined>(undefined) |
|
0 commit comments