외부 DB 연결 설정 및 쿼리 처리 로직 보완
This commit is contained in:
@@ -119,18 +119,29 @@ export default function HierarchyConfigPanel({
|
||||
tablesToLoad.push(hierarchyConfig.material.tableName);
|
||||
}
|
||||
|
||||
// 중복 제거 후 로드
|
||||
// 중복 제거 후, 아직 캐시에 없는 테이블만 병렬로 로드
|
||||
const uniqueTables = [...new Set(tablesToLoad)];
|
||||
for (const tableName of uniqueTables) {
|
||||
if (!columnsCache[tableName]) {
|
||||
try {
|
||||
const columns = await onLoadColumns(tableName);
|
||||
const normalized = normalizeColumns(columns);
|
||||
setColumnsCache((prev) => ({ ...prev, [tableName]: normalized }));
|
||||
} catch (error) {
|
||||
console.error(`컬럼 로드 실패 (${tableName}):`, error);
|
||||
}
|
||||
}
|
||||
const tablesToFetch = uniqueTables.filter((tableName) => !columnsCache[tableName]);
|
||||
|
||||
if (tablesToFetch.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
setLoadingColumns(true);
|
||||
try {
|
||||
await Promise.all(
|
||||
tablesToFetch.map(async (tableName) => {
|
||||
try {
|
||||
const columns = await onLoadColumns(tableName);
|
||||
const normalized = normalizeColumns(columns);
|
||||
setColumnsCache((prev) => ({ ...prev, [tableName]: normalized }));
|
||||
} catch (error) {
|
||||
console.error(`컬럼 로드 실패 (${tableName}):`, error);
|
||||
}
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
setLoadingColumns(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user