Skip to content

Commit

Permalink
fix accidentally quadratic behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Nov 25, 2020
1 parent 701da2e commit d095329
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ui/app/serializers/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ export default class VolumeSerializer extends ApplicationSerializer {
// Populate read/write allocation lists from aggregate allocation list
const readAllocs = hash.ReadAllocs || {};
const writeAllocs = hash.WriteAllocs || {};
const bindIDToAlloc = allocList => id => {
const alloc = allocList.find(a => a.ID === id);
return alloc;
};

hash.ReadAllocations = Object.keys(readAllocs).map(bindIDToAlloc(hash.Allocations));
hash.WriteAllocations = Object.keys(writeAllocs).map(bindIDToAlloc(hash.Allocations));
if (hash.Allocations) {
hash.ReadAllocations = [];
hash.WriteAllocations = [];

hash.Allocations.forEach(function(alloc) {
const id = alloc.ID;
if (id in readAllocs) {
hash.ReadAllocations.push(alloc);
}
if (id in writeAllocs) {
hash.WriteAllocations.push(alloc);
}
});
delete hash.Allocations;
}

const normalizedHash = super.normalize(typeHash, hash);
return this.extractEmbeddedRecords(this, this.store, typeHash, normalizedHash);
Expand Down

0 comments on commit d095329

Please sign in to comment.