Skip to content

Commit

Permalink
Merge pull request ABI-Software#72 from Tehsurfer/anatomy-markers
Browse files Browse the repository at this point in the history
Anatomy markers
  • Loading branch information
alan-wu authored Jun 25, 2024
2 parents 48024c1 + f070712 commit db0e070
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abi-software/map-side-bar",
"version": "2.2.0",
"version": "2.2.1-alpha-3",
"files": [
"dist/*",
"src/*",
Expand Down
35 changes: 33 additions & 2 deletions src/algolia/algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,46 @@ export class AlgoliaClient {
filters: filter,
attributesToHighlight: [],
attributesToRetrieve: [
'objectID',
'item.keywords.keyword',
'anatomy.organ.name',
'anatomy.organ.curie'
],
})
.then(response => {
let anatomyAsUberons = this._processAnatomy(response.hits)
resolve(anatomyAsUberons)
// Saving the line below incase we want to starty using keywords again
// let anatomyAsUberons = this._processAnatomy(response.hits)

resolve({
forFlatmap: this.processResultsForFlatmap(response.hits),
forScaffold: this.processResultsForScaffold(response.hits)
})
})
})
}
processResultsForFlatmap(hits) {
let curieForDatsets = hits.map(h=>({
id: h.objectID,
terms: h.anatomy? h.anatomy.organ.map(o=>o.curie) : []
}))
return curieForDatsets
}
processResultsForScaffold(hits) {
let numberOfDatasetsForAnatomy = {}
hits.forEach(hit => {
if (hit.anatomy && hit.anatomy.organ ) {
hit.anatomy.organ.forEach(anatomy => {
if (anatomy.name) {
if (numberOfDatasetsForAnatomy[anatomy.name]) {
numberOfDatasetsForAnatomy[anatomy.name]++
} else {
numberOfDatasetsForAnatomy[anatomy.name] = 1
}
}
})
}
})
return numberOfDatasetsForAnatomy
}

}
23 changes: 16 additions & 7 deletions src/components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,25 @@ export default {
*/
this.$emit('actionClick', payLoad)
})
EventBus.on('available-facets', (payLoad) => {
this.$emit('search-changed', {
type: 'available-facets',
value: payLoad,
})
EventBus.on('number-of-datasets-for-anatomies', (payLoad) => {
/**
* This emits a object with keys as anatomy and values as number of datasets for that anatomy.
* @arg payload
*/
this.$emit('number-of-datasets-for-anatomies', payLoad)
})
EventBus.on('anatomy-in-datasets', (payLoad) => {
/**
* This emits a lis of datasets, with the anatomy for each one. Used by flatmap for markers
* @arg payload
*/
this.$emit('anatomy-in-datasets', payLoad)
})
EventBus.on('contextUpdate', (payLoad) => {
/**
* This event is emitted when the context is updated.
* Example, context update on first load.
* This event is emitted when the context card is updated.
* Example, context card update on first load.
* @arg payload
*/
this.$emit('contextUpdate', payLoad)
Expand Down
10 changes: 5 additions & 5 deletions src/components/SidebarContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ export default {
},
searchAlgolia(filters, query = '') {
// Algolia search
this.loadingCards = true
this.algoliaClient
.anatomyInSearch(getFilters(filters), query)
.then((anatomy) => {
EventBus.emit('available-facets', {
uberons: anatomy,
labels: this.algoliaClient.anatomyFacetLabels,
})
.then((r) => {
// Send result anatomy to the scaffold and flatmap
EventBus.emit('anatomy-in-datasets', r.forFlatmap)
EventBus.emit('number-of-datasets-for-anatomies', r.forScaffold)
})
this.algoliaClient
.search(getFilters(filters), query, this.numberPerPage, this.page)
Expand Down

0 comments on commit db0e070

Please sign in to comment.