buster/web/src/api/buster_rest/metrics/queryReqestsServer.ts

25 lines
705 B
TypeScript
Raw Normal View History

2025-03-28 06:51:03 +08:00
import { metricsQueryKeys } from '@/api/query_keys/metric';
import { upgradeMetricToIMetric } from '@/lib/metrics';
import { QueryClient } from '@tanstack/react-query';
2025-04-02 01:04:19 +08:00
import { getMetric_server } from './requests';
2025-03-28 06:51:03 +08:00
/*
*/
2025-03-28 06:51:03 +08:00
export const prefetchGetMetric = async (
params: Parameters<typeof getMetric_server>[0],
queryClientProp?: QueryClient
) => {
const queryClient = queryClientProp || new QueryClient();
2025-04-08 06:11:33 +08:00
2025-03-28 06:51:03 +08:00
await queryClient.prefetchQuery({
2025-04-17 13:47:14 +08:00
...metricsQueryKeys.metricsGetMetric(params.id, params.version_number || null),
2025-03-28 06:51:03 +08:00
queryFn: async () => {
const result = await getMetric_server(params);
return upgradeMetricToIMetric(result, null);
}
});
return queryClient;
};