Skip to content

Commit

Permalink
Load concept data for suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Aug 7, 2024
1 parent cb1ee50 commit da76365
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,27 @@ watch(() => state.ppn, async (ppn) => {
// Load concept data for mappings
console.time("Load concept data for mappings")
// TODO
const suggestionsGroupedByScheme = state.schemes.map(scheme => ({ scheme, concepts: suggestions.filter(({ target }) => jskos.compare(target.inScheme[0], scheme)).map(({ target }) => target) })).filter(group => group.concepts.length)
// TODO: Fix code repetition from above
await Promise.all(suggestionsGroupedByScheme.map(async ({ scheme, concepts: conceptsToLoad }) => {
console.log(scheme, conceptsToLoad)
if (!scheme.API?.length || !scheme._registry) {
return
}
let concepts
try {
concepts = await scheme._registry.getConcepts({ concepts: conceptsToLoad.map(subject => ({ uri: subject.uri })) })
} catch (error) {
console.warn(`Could not load concept data for ${jskos.notation(scheme)} concepts`, error)
return []
}
concepts.forEach(loadedConcept => {
const concept = conceptsToLoad.find(s => jskos.compare(s, loadedConcept))
if (concept) {
concept.prefLabel = loadedConcept.prefLabel
}
})
}))
console.timeEnd("Load concept data for mappings")
state.loading = false
Expand Down Expand Up @@ -324,7 +344,7 @@ const examples = [
v-for="{ target, mappings } in state.suggestions"
:key="target.uri">
<td>{{ jskos.notation(target.inScheme[0]) }}</td>
<td>{{ jskos.notation(target) }}</td>
<td>{{ jskos.notation(target) }} {{ jskos.prefLabel(target, { fallbackToUri: false }) }}</td>
<td>
<ul class="plainList">
<li
Expand Down

0 comments on commit da76365

Please sign in to comment.