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

24 lines
696 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();
await queryClient.prefetchQuery({
...metricsQueryKeys.metricsGetMetric(params.id, params.version_number),
queryFn: async () => {
const result = await getMetric_server(params);
return upgradeMetricToIMetric(result, null);
}
});
return queryClient;
};