• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / codegate-ui / 12863331275

20 Jan 2025 07:49AM CUT coverage: 66.312% (+0.5%) from 65.795%
12863331275

Pull #119

github

web-flow
Merge fd5d5c813 into faa17e877
Pull Request #119: fix: version endpoint

228 of 420 branches covered (54.29%)

Branch coverage included in aggregate %.

10 of 11 new or added lines in 2 files covered. (90.91%)

457 of 613 relevant lines covered (74.55%)

59.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/features/dashboard-codegate-status/hooks/use-codegate-status.ts
1
import { queryOptions, useQuery } from "@tanstack/react-query";
2

3
import {
4
  PollingInterval,
5
  POLLING_INTERVAl,
6
} from "../components/codegate-status-polling-control";
7
import { healthCheckHealthGet, v1VersionCheck } from "@/api/generated";
8
import { HealthStatus, VersionResponse } from "../types";
9

10
type HealthResponse = { status: "healthy" | unknown } | null;
11

12
const getCodeGateHealth = async (): Promise<HealthStatus | null> => {
3✔
13
  const data = (await healthCheckHealthGet()).data;
16✔
14

15
  if ((data as HealthResponse)?.status === "healthy")
15✔
16
    return HealthStatus.HEALTHY;
1✔
17
  if ((data as HealthResponse)?.status !== "healthy")
14!
18
    return HealthStatus.UNHEALTHY;
14✔
19

NEW
20
  return null;
×
21
};
22

23
const getVersion = async (): Promise<VersionResponse | null> => {
3✔
24
  return ((await v1VersionCheck()).data as VersionResponse) ?? null;
15!
25
};
26

27
export function getQueryOptionsCodeGateStatus(
28
  pollingInterval: PollingInterval,
29
) {
30
  return queryOptions({
184✔
31
    queryFn: async () => {
32
      const health = await getCodeGateHealth();
16✔
33
      const version = await getVersion();
15✔
34

35
      return {
14✔
36
        health,
37
        version: version as VersionResponse | null,
38
      };
39
    },
40
    queryKey: ["useHealthCheck", { pollingInterval }],
41
    refetchInterval: POLLING_INTERVAl[pollingInterval].value,
42
    staleTime: Infinity,
43
    gcTime: Infinity,
44
    refetchIntervalInBackground: true,
45
    refetchOnMount: true,
46
    refetchOnReconnect: true,
47
    refetchOnWindowFocus: true,
48
    retry: false,
49
  });
50
}
51

52
export const useCodeGateStatus = (pollingInterval: PollingInterval) =>
3✔
53
  useQuery({
91✔
54
    ...getQueryOptionsCodeGateStatus(pollingInterval),
55
  });
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc