Skip to content

Commit 3f2aa96

Browse files
committed
Hardening | mark algo done state
1 parent ebc4630 commit 3f2aa96

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

src/components/map-projects/MapProject.jsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,24 +2106,22 @@ const MapProject = () => {
21062106
return
21072107
}
21082108
log({action: 'algo_finished', extras: {algo: algoId}}, __row.__index)
2109-
markAlgo(__row.__index, algoId, 1)
21102109
let data = isArray(response) ? response : (response?.data || [])
2111-
setAllCandidates(prev => {
2112-
let nextCandidates
2113-
if(offset === 0) {
2114-
const results = algoId === 'ocl-scispacy-loinc' ? [{row: __row, results: fromScispacyResultsToConcepts(get(response.data, __row.__index) || [])}] : data
2115-
nextCandidates = {...prev, [algoId]: [...reject(prev[algoId], c => c.row.__index === __row.__index), ...(results || [])]}
2116-
lookupCandidates(algoId, get(results, '0.results'))
2117-
} else {
2118-
const newMatches = [...(prev[algoId] || [])]
2119-
const index = findIndex(newMatches, match => match.row.__index === __row.__index)
2120-
newMatches[index].results = [...newMatches[index].results, ...(get(data, '0.results') || [])]
2121-
lookupCandidates(algoId, get(data, '0.results'))
2122-
nextCandidates = {...prev, [algoId]: newMatches}
2123-
}
2124-
allCandidatesRef.current = nextCandidates
2125-
return nextCandidates
2126-
})
2110+
let nextCandidates
2111+
if(offset === 0) {
2112+
const results = algoId === 'ocl-scispacy-loinc' ? [{row: __row, results: fromScispacyResultsToConcepts(get(response.data, __row.__index) || [])}] : data
2113+
nextCandidates = {...allCandidatesRef.current, [algoId]: [...reject(allCandidatesRef.current[algoId], c => c.row.__index === __row.__index), ...(results || [])]}
2114+
lookupCandidates(algoId, get(results, '0.results'))
2115+
} else {
2116+
const newMatches = [...(allCandidatesRef.current[algoId] || [])]
2117+
const index = findIndex(newMatches, match => match.row.__index === __row.__index)
2118+
newMatches[index].results = [...newMatches[index].results, ...(get(data, '0.results') || [])]
2119+
lookupCandidates(algoId, get(data, '0.results'))
2120+
nextCandidates = {...allCandidatesRef.current, [algoId]: newMatches}
2121+
}
2122+
allCandidatesRef.current = nextCandidates
2123+
setAllCandidates(nextCandidates)
2124+
markAlgo(__row.__index, algoId, 1)
21272125
setIsLoadingInDecisionView(false)
21282126
let items = get(response?.data, '0.results') || []
21292127
if(items.length > 0){

0 commit comments

Comments
 (0)