Skip to content

Commit 543825c

Browse files
committed
OpenConceptLab/ocl_issues#2300 | fetching CIEL's mapped sources
1 parent c68938e commit 543825c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/components/map-projects/MapProject.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const MapProject = () => {
195195
const [repo, setRepo] = React.useState(false)
196196
const [repoVersion, setRepoVersion] = React.useState(false)
197197
const [mappedSources, setMappedSources] = React.useState([])
198+
const [CIELMappedSources, setCIELMappedSources] = React.useState([])
198199
const [locales, setLocales] = React.useState([])
199200
const [isLoadingLocales, setIsLoadingLocales] = React.useState(false)
200201
const [versions, setVersions] = React.useState([])
@@ -901,15 +902,15 @@ const MapProject = () => {
901902

902903
const fetchRepo = (url, _repo) => APIService.new().overrideURL(url).get().then(response => setRepo(response.data?.id ? response.data : _repo))
903904

904-
const fetchMappedSources = url => {
905+
const fetchMappedSources = (url, setter) => {
905906
let limit = 25
906907

907908
const recurse = (offset, page, fetchedSoFar, accumulated) => {
908909
_fetchMappedSources(url, limit, offset, page, response => {
909910
const data = response?.data || []
910911
const updated = [...accumulated, ...data]
911912

912-
setMappedSources(updated)
913+
setter(updated)
913914

914915
const fetched = fetchedSoFar + data.length
915916
const numFound = parseInt(response?.headers?.num_found || 0)
@@ -943,7 +944,9 @@ const MapProject = () => {
943944
setRepoVersion(version)
944945
if(version?.version_url) {
945946
fetchLocaleDistribution(version.version_url)
946-
fetchMappedSources(version.version_url)
947+
fetchMappedSources(version.version_url, setMappedSources)
948+
if(isEmpty(CIELMappedSources))
949+
fetchMappedSources('/orgs/CIEL/sources/CIEL/', setCIELMappedSources)
947950
updateAlgosByRepoVersion(version)
948951
}
949952
}
@@ -2611,7 +2614,7 @@ const MapProject = () => {
26112614
limit={CANDIDATES_LIMIT}
26122615
user={user}
26132616
ref={bridgeRef}
2614-
mappedRepoURLs={mappedSources.map(source => source.url)}
2617+
mappedRepoURLs={CIELMappedSources.map(source => source.url)}
26152618
/>
26162619
}
26172620
{

0 commit comments

Comments
 (0)