@@ -1121,14 +1121,10 @@ const MapProject = () => {
11211121 } ;
11221122
11231123 // Function to handle concurrency
1124- const processWithConcurrency = async ( _repo , algo ) => {
1124+ const processWithConcurrency = async ( _repo , algo , _rows ) => {
11251125 const CHUNK_SIZE = algo . batch_size || 10 // Number of rows per batch
11261126 const MAX_CONCURRENT_REQUESTS = algo . concurrent_requests || 1 ; // Number of parallel API requests allowed
1127- if ( autoMatchUnmappedOnly )
1128- rows = filter ( rows , row => rowStatuses . unmapped . includes ( row . __index ) )
1129- else
1130- rows = filter ( rows , row => ! rowStatuses . reviewed . includes ( row . __index ) )
1131- const rowChunks = chunk ( rows , CHUNK_SIZE ) ;
1127+ const rowChunks = chunk ( _rows , CHUNK_SIZE ) ;
11321128
11331129 const queue = rowChunks . slice ( ) ; // Copy of all chunks to be processed
11341130 const activeRequests = new Set ( ) ;
@@ -1212,21 +1208,27 @@ const MapProject = () => {
12121208 setRowStatuses ( prev => ( { ...prev , readyForReview : [ ] } ) )
12131209
12141210 setTimeout ( async ( ) => {
1211+ const rowsToProcess = autoMatchUnmappedOnly
1212+ ? filter ( rows , row => rowStatuses . unmapped . includes ( row . __index ) )
1213+ : filter ( rows , row => ! rowStatuses . reviewed . includes ( row . __index ) )
1214+
12151215 let nextAlgo = { ...getFirstAlgoDef ( ) }
1216+ const algoPromises = [ ]
12161217 while ( nextAlgo ?. id ) {
12171218 if ( [ 'custom' , 'ocl-search' , 'ocl-semantic' ] . includes ( nextAlgo . type ) )
1218- await processWithConcurrency ( repo , nextAlgo ) ;
1219+ algoPromises . push ( processWithConcurrency ( repo , nextAlgo , rowsToProcess ) ) ;
12191220 else if ( nextAlgo . type === 'ocl-ciel-bridge' && canBridge )
1220- await fetchBulkBridgeCandidates ( rows , nextAlgo )
1221+ algoPromises . push ( fetchBulkBridgeCandidates ( rowsToProcess , nextAlgo ) )
12211222 else if ( nextAlgo . type === 'ocl-scispacy' && canScispacy )
1222- await fetchBulkScispacyCandidates ( rows , nextAlgo )
1223+ algoPromises . push ( fetchBulkScispacyCandidates ( rowsToProcess , nextAlgo ) )
12231224 nextAlgo = getNextAlgoDef ( nextAlgo . id )
12241225 }
1226+ await Promise . all ( algoPromises )
12251227
1226- await processRerankWithConcurrency ( rows , 2 )
1228+ await processRerankWithConcurrency ( rowsToProcess , 2 )
12271229 if ( inAIAssistantGroup && autoRunAIAnalysis ) {
12281230 await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
1229- await runBulkAIAnalysis ( rows )
1231+ await runBulkAIAnalysis ( rowsToProcess )
12301232 } else {
12311233 setLoadingMatches ( false )
12321234 setEndMatchingAt ( moment ( ) )
0 commit comments