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

pull/10792/head
Matt Hook 2024-04-09 15:50:48 +12:00 committed by GitHub
parent c95ffa9e2d
commit 8913e75484
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(
environmentId,
namespaceNames
namespaceNames,
{ lookupApplications: false }
);
const { data: ingresses, ...ingressesQuery } = useIngresses(
environmentId,

View File

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

View File

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