Skip to content

Commit

Permalink
Refactor otus match proxys to make a call for each param #468
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Sep 11, 2018
1 parent 23e0587 commit 113be9f
Showing 1 changed file with 23 additions and 1 deletion.
Expand Up @@ -56,6 +56,7 @@
return {
otu_name_list: [],
otu_id_list: [],
processingList: false
}
},
watch: {
Expand Down Expand Up @@ -85,8 +86,18 @@
this.otu_id_list = response.body;
let params = { otu_ids: this.getIdsList(this.otu_id_list) };
this.$http.get('/otus.json', { params: params }).then(response => {
let promises = []
this.otu_name_list = response.body;
this.processTypes()
promises.push(this.processType(this.getIdsList(this.taxon_names_cites), 'taxon_name_ids'))
promises.push(this.processType(this.getIdsList(this.taxon_relationship_cites), 'taxon_name_relationship_ids'))
promises.push(this.processType(this.getIdsList(this.taxon_classification_cites), 'taxon_name_classification_ids'))
promises.push(this.processType(this.getIdsList(this.biological_association_cites), 'biological_association_ids'))
promises.push(this.processType(this.getIdsList(this.distribution_cites), 'asserted_distribution_ids'))
Promise.all(promises).then(lists => {
this.otu_id_list = [].concat.apply([], lists)
})
})
})
},
Expand All @@ -96,6 +107,17 @@
getIdsList(list) {
return list.map((item) => { return item.citation_object_id })
},
processType(list, type) {
return new Promise((resolve, reject) => {
let params = {
[type]: list
}
this.$http.get('/otus.json', { params: params }).then(response => {
response.body.forEach(this.addOtu);
resolve(response.body)
})
})
},
processTypes() {
let params = {
taxon_name_ids: this.getIdsList(this.taxon_names_cites),
Expand Down

0 comments on commit 113be9f

Please sign in to comment.