Browse Source

Merge pull request #8747 from nocodb/nc-fix/erd-meta-fetch

fix: ERD - avoid fetching non-source table metas
pull/8751/head
Pranav C 5 months ago committed by GitHub
parent
commit
e7d6664e6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nc-gui/components/erd/View.vue

22
packages/nc-gui/components/erd/View.vue

@ -45,16 +45,28 @@ const config = reactive<ERDConfig>({
isFullScreen: false,
})
const loadMetaOfTablesNotInMetas = async (localTables: TableType[]) => {
const fetchMissingTableMetas = async (localTables: TableType[]) => {
const chunkSize = 5
// Function to process a chunk of tables
const processChunk = async (chunk: TableType[]) => {
await Promise.all(
localTables
.filter((table) => !metas.value[table.id!])
.map(async (table) => {
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 () => {
let localTables: TableType[] = []
if (props.table) {
@ -73,7 +85,7 @@ const populateTables = async () => {
localTables = baseTables.value
}
await loadMetaOfTablesNotInMetas(localTables)
await fetchMissingTableMetas(localTables)
tables.value = localTables
.filter(

Loading…
Cancel
Save