Skip to content
Snippets Groups Projects
Commit 3a799117 authored by David Hoksza's avatar David Hoksza
Browse files

fixing multiple occurences of the same disease in suggestions due to case sensitivity

parent 569f3f6a
No related branches found
No related tags found
No related merge requests found
Pipeline #9978 canceled
......@@ -316,7 +316,7 @@ function initMainPageStructure(container){
{
name: 'diseases',
source: typeaheadSource
, limit: 10
, limit: 30
});
pluginContainer.find('.typeahead').bind('typeahead:select', (ev, suggestion) => typeaheadSelect(ev, suggestion));
......
......@@ -7,17 +7,30 @@ const getDisease = function(iri){
});
};
const suggestDiseases = function (text) {
const caseInsensitive = function(value, index, self){
const iVal = value.autosuggest.toLowerCase();
for (let i = 0; i < self.length; i++){
if (self[i].autosuggest.toLowerCase() === iVal) {
return i === index;
}
}
};
let suggestedDisDesc = []; //array of suggestion-disease description pair
return $.ajax({
url: `https://www.ebi.ac.uk/ols/api/suggest?q=${encodeURIComponent(text)}&ontology=efo&rows=20`
}).then(function (res) {
const suggestions = res.response.docs.map(d => {
suggestedDisDesc.push({suggestion: d.autosuggest, desc: undefined});
return d.autosuggest;
});
const suggestions = res.response.docs
.filter(caseInsensitive)
.map(d => {
suggestedDisDesc.push({suggestion: d.autosuggest, desc: undefined});
return d.autosuggest;
});
const promises = suggestions.map(s => $.ajax({url: `https://www.ebi.ac.uk/ols/api/search?q=${encodeURIComponent(s)}&ontology=efo&queryFields=label,synonym&exact=true`}))
return Promise.all(promises);
}).then(function (ress) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment