From 09ce14f31fd0ea9551e7851b9accbe176b02b26a Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 12 Oct 2025 10:07:03 +0300 Subject: [PATCH] Cache node account id --- frontend/kubecloud/src/composables/useNodes.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/kubecloud/src/composables/useNodes.ts b/frontend/kubecloud/src/composables/useNodes.ts index dc102482..e669df03 100644 --- a/frontend/kubecloud/src/composables/useNodes.ts +++ b/frontend/kubecloud/src/composables/useNodes.ts @@ -20,6 +20,7 @@ export interface NodeFilters { grid_version?: number region?: string } +const accountIdCache = new Map() export function useNodes() { const nodes = ref([]) @@ -128,8 +129,14 @@ export function useNodes() { // Fetch account id for a twin id async function fetchAccountId(twinId: number): Promise { try { + if(accountIdCache.has(twinId)){ + return accountIdCache.get(twinId)! + } + const response = await userService.getTwinAccount(twinId) - return response.account_id + const accountId = response.account_id + accountIdCache.set(twinId, accountId) + return accountId } catch (err: any) { console.error('Failed to fetch account id:', err) return ''