mirror of
https://github.com/nasa/openmct.git
synced 2025-05-29 13:44:21 +00:00
[Persistence] Fix bug in id filtering
Fix bug when filtering out namespaced identifiers when reading domain object models from persistence; filter operation was breaking the logic of pairing ids back to loaded models by index. Corrects behavior introduced to reduce latency when loading the telemetry hierarchy, part of WARP Server integration, WTD-644.
This commit is contained in:
parent
11f6175592
commit
b98758daf8
@ -20,22 +20,30 @@ define(
|
||||
* models should be retrieved.
|
||||
*/
|
||||
function PersistedModelProvider(persistenceService, $q, SPACE) {
|
||||
// Load a single object model from persistence
|
||||
function loadModel(id) {
|
||||
return persistenceService.readObject(SPACE, id);
|
||||
}
|
||||
|
||||
// Promise all persisted models (in id->model form)
|
||||
function promiseModels(ids) {
|
||||
return $q.all(ids.filter(function (id) {
|
||||
// Filter out "namespaced" identifiers; these are
|
||||
// not expected to be found in database. See WTD-659.
|
||||
return id.indexOf(":") === -1;
|
||||
}).map(function (id) {
|
||||
// Read remaining objects from persistence
|
||||
return persistenceService.readObject(SPACE, id);
|
||||
})).then(function (models) {
|
||||
// Packaged the result as id->object
|
||||
// Package the result as id->model
|
||||
function packageResult(models) {
|
||||
var result = {};
|
||||
ids.forEach(function (id, index) {
|
||||
result[id] = models[index];
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// Filter out "namespaced" identifiers; these are
|
||||
// not expected to be found in database. See WTD-659.
|
||||
ids = ids.filter(function (id) {
|
||||
return id.indexOf(":") === -1;
|
||||
});
|
||||
|
||||
// Give a promise for all persistence lookups...
|
||||
return $q.all(ids.map(loadModel)).then(packageResult);
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user