Skip to content

Commit af50d73

Browse files
authored
Merge pull request #1523 from rocket-admin/backend_charts
feat: enhance AI scan to skip existing tables
2 parents 4f72f2c + af2c901 commit af50d73

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

backend/src/entities/shared-jobs/shared-jobs.service.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,27 @@ export class SharedJobsService {
3232
}
3333
console.info(`Starting AI scan for connection with id "${connection.id}"`);
3434
try {
35+
const existingTableSettings = await this._dbContext.tableSettingsRepository.find({
36+
where: {
37+
connection_id: {
38+
id: connection.id,
39+
},
40+
},
41+
});
42+
43+
const existingTableNames = new Set(existingTableSettings.map((setting) => setting.table_name));
3544
const dao = getDataAccessObject(connection);
3645
const tables: Array<TableDS> = await dao.getTablesFromDB();
46+
const tablesToScan = tables.filter((table) => !existingTableNames.has(table.tableName));
47+
48+
if (tablesToScan.length === 0) {
49+
console.info(`No new tables to scan for connection with id "${connection.id}"`);
50+
return;
51+
}
52+
3753
const queue = new PQueue({ concurrency: 4 });
3854
const tablesInformation = await Promise.all(
39-
tables.map((table) =>
55+
tablesToScan.map((table) =>
4056
queue.add(async () => {
4157
const structure = await dao.getTableStructure(table.tableName, null);
4258
const primaryColumns = await dao.getTablePrimaryColumns(table.tableName, null);

0 commit comments

Comments
 (0)