All files / src/hooks usePings.ts

100% Statements 21/21
100% Branches 4/4
100% Functions 4/4
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x 1x   1x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x   1x 2x 2x 2x 2x 2x 2x 2x  
import { useQuery } from "@tanstack/react-query";
import { getMonitorPings, getMonitorStats } from "../api/pings";
 
export function useMonitorPings(
  monitorId: string,
  skip: number = 0,
  limit: number = 10,
) {
  return useQuery({
    queryKey: ["pings", monitorId, skip, limit],
    queryFn: () => getMonitorPings(monitorId, skip, limit),
    enabled: !!monitorId,
  });
}
 
export function useMonitorStats(monitorId: string) {
  return useQuery({
    queryKey: ["ping-stats", monitorId],
    queryFn: () => getMonitorStats(monitorId),
    enabled: !!monitorId,
    refetchInterval: 60000, // Refresh every minute
  });
}