File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
backend/src/entities/shared-jobs Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments