Commit 9e4f176f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fetch reactions and aliases in parallel

parent bdc03780
minerva (16.0.6) stable; urgency=medium
* Bug fix (performance): fetching all bioEntities using plugin API is faster;
reactions and elements are fetched in parallel (#1605)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 16 Dec 2021 11:00:00 +0200
minerva (16.0.5) stable; urgency=medium
* Bug fix (performance): uploading of data overlays was time consuming
(#1591)
......
......@@ -125,20 +125,22 @@ function MapModel(configuration) {
*/
MapModel.prototype.getAliases = function (params) {
var self = this;
var columns = "id,bounds,modelId,linkedSubmodel";
if (params.complete) {
columns = undefined;
}
return ServerConnector.getAliases({
columns: "id,modelId",
columns: columns,
type: params.type,
modelId: self.getId(),
includedCompartmentIds: params.includedCompartmentIds,
excludedCompartmentIds: params.excludedCompartmentIds
}).then(function (lightAliases) {
var identifiedElements = [];
for (var i = 0; i < lightAliases.length; i++) {
self.addAlias(lightAliases[i]);
identifiedElements.push(new IdentifiedElement(lightAliases[i]));
}).then(function (aliases) {
for (var i = 0; i < aliases.length; i++) {
self.addAlias(aliases[i]);
}
return self.getByIdentifiedElements(identifiedElements, params.complete);
return aliases;
});
};
......@@ -822,6 +824,41 @@ MapModel.prototype.getReactionsForElements = function (elements, complete) {
});
};
/**
*
* @return {Promise}
*/
MapModel.prototype.getReactions = function ( ) {
var self = this;
var result = [];
return ServerConnector.getReactions({
modelId: self.getId()
}).then(function (reactions) {
result = reactions;
for (var i = 0; i < reactions.length; i++) {
var reaction = reactions[i];
var id = reaction.getId();
if (self._reactions[id] === undefined) {
self._reactions[id] = reaction;
} else {
self._reactions[id].update(reaction);
}
}
var ids = self._getMissingReactionsElementIds(reactions);
return self.getMissingElements({
aliasIds: ids,
complete: true
});
}).then(function () {
var promises = [];
for (var i = 0; i < result.length; i++) {
promises.push(self.getCompleteReactionById(result[i].getId()));
}
return Promise.all(promises);
});
};
/**
*
* @returns {Promise}
......
......@@ -280,20 +280,12 @@ function createProjectData(options) {
type: map.getConfiguration().getSimpleElementTypeNames(),
complete: true
}));
promises.push(models[i].getReactions());
}
return Promise.all(promises).then(function (aliasesByModel) {
var promises = [];
for (var i = 0; i < models.length; i++) {
promises.push(models[i].getReactionsForElements(aliasesByModel[i], true));
for (var j = 0; j < aliasesByModel[i].length; j++) {
result.push(aliasesByModel[i][j]);
}
}
return Promise.all(promises);
}).then(function (reactionsByModel) {
for (var i = 0; i < models.length; i++) {
for (var j = 0; j < reactionsByModel[i].length; j++) {
result.push(reactionsByModel[i][j]);
return Promise.all(promises).then(function (bioEntitiesLists) {
for (var i = 0; i < bioEntitiesLists.length; i++) {
for (var j = 0; j < bioEntitiesLists[i].length; j++) {
result.push(bioEntitiesLists[i][j]);
}
}
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment