fix(services): speed up service count on the kubernetes dashboard [EE-6967] (#11524)

pull/11538/head
Matt Hook 2024-04-09 15:50:39 +12:00 committed by GitHub
parent 13cee9975c
commit 399ddaea3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -34,7 +34,8 @@ export function DashboardView() {
); );
const { data: services, ...servicesQuery } = useServicesForCluster( const { data: services, ...servicesQuery } = useServicesForCluster(
environmentId, environmentId,
namespaceNames namespaceNames,
{ lookupApplications: false }
); );
const { data: ingresses, ...ingressesQuery } = useIngresses( const { data: ingresses, ...ingressesQuery } = useIngresses(
environmentId, environmentId,

View File

@ -42,6 +42,7 @@ export function ServicesDatatable() {
namespaceNames, namespaceNames,
{ {
autoRefreshRate: tableState.autoRefreshRate * 1000, autoRefreshRate: tableState.autoRefreshRate * 1000,
lookupApplications: true,
} }
); );

View File

@ -22,7 +22,7 @@ export const queryKeys = {
export function useServicesForCluster( export function useServicesForCluster(
environmentId: EnvironmentId, environmentId: EnvironmentId,
namespaceNames?: string[], namespaceNames?: string[],
options?: { autoRefreshRate?: number } options?: { autoRefreshRate?: number; lookupApplications?: boolean }
) { ) {
return useQuery( return useQuery(
queryKeys.clusterServices(environmentId), queryKeys.clusterServices(environmentId),
@ -32,7 +32,7 @@ export function useServicesForCluster(
} }
const settledServicesPromise = await Promise.allSettled( const settledServicesPromise = await Promise.allSettled(
namespaceNames.map((namespace) => namespaceNames.map((namespace) =>
getServices(environmentId, namespace, true) getServices(environmentId, namespace, options?.lookupApplications)
) )
); );
return compact( return compact(
@ -87,14 +87,14 @@ export function useMutationDeleteServices(environmentId: EnvironmentId) {
export async function getServices( export async function getServices(
environmentId: EnvironmentId, environmentId: EnvironmentId,
namespace: string, namespace: string,
lookupApps: boolean lookupApplications?: boolean
) { ) {
try { try {
const { data: services } = await axios.get<Array<Service>>( const { data: services } = await axios.get<Array<Service>>(
`kubernetes/${environmentId}/namespaces/${namespace}/services`, `kubernetes/${environmentId}/namespaces/${namespace}/services`,
{ {
params: { params: {
lookupapplications: lookupApps, lookupapplications: lookupApplications,
}, },
} }
); );