외부 DB 연결 설정 및 쿼리 처리 로직 보완

This commit is contained in:
dohyeons 2025-11-25 14:57:48 +09:00
parent ace80be8e1
commit 080188b419
2 changed files with 27 additions and 11 deletions

View File

@ -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);
}
};

View File

@ -290,8 +290,13 @@ export class ExternalDbConnectionAPI {
static async getTableColumns(connectionId: number, tableName: string): Promise<ApiResponse<any[]>> {
try {
console.log("컬럼 정보 API 요청:", `${this.BASE_PATH}/${connectionId}/tables/${tableName}/columns`);
// 컬럼 메타데이터 조회는 외부 DB 성능/네트워크 영향으로 오래 걸릴 수 있으므로
// 기본 30초보다 넉넉한 타임아웃을 사용
const response = await apiClient.get<ApiResponse<any[]>>(
`${this.BASE_PATH}/${connectionId}/tables/${tableName}/columns`,
{
timeout: 120000, // 120초
},
);
console.log("컬럼 정보 API 응답:", response.data);
return response.data;