From 71d3d68dbf3520b725953e0b6a737c47d19eed36 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 14 Jun 2024 10:57:26 +0000 Subject: [PATCH] fix: exclude other sources tables when fetching meta for ERD --- packages/nc-gui/components/erd/View.vue | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/erd/View.vue b/packages/nc-gui/components/erd/View.vue index 367dab8260..9887f7e5fd 100644 --- a/packages/nc-gui/components/erd/View.vue +++ b/packages/nc-gui/components/erd/View.vue @@ -46,13 +46,25 @@ const config = reactive({ }) const loadMetaOfTablesNotInMetas = async (localTables: TableType[]) => { - await Promise.all( - localTables - .filter((table) => !metas.value[table.id!] && table.source_id === props.sourceId) - .map(async (table) => { + const chunkSize = 5 + + // Function to process a chunk of tables + const processChunk = async (chunk: TableType[]) => { + await Promise.all( + chunk.map(async (table) => { await getMeta(table.id!) }), - ) + ) + } + + // filter out tables that are already loaded and are not from the same source + const filteredTables = localTables.filter((t) => !metas.value[t.id!] && t.source_id === props.sourceId) + + // Split the tables into chunks and process each chunk sequentially to avoid hitting throttling limits + for (let i = 0; i < filteredTables.length; i += chunkSize) { + const chunk = filteredTables.slice(i, i + chunkSize) + await processChunk(chunk) + } } const populateTables = async () => {