From efdce6859e9ded2b7c652263c22195621e57ad6f Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 25 Nov 2020 15:47:33 -0500 Subject: [PATCH] fix accidentally quadratic behavior --- ui/app/serializers/volume.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ui/app/serializers/volume.js b/ui/app/serializers/volume.js index 8f2acad3b0e..c3aa3a57dc4 100644 --- a/ui/app/serializers/volume.js +++ b/ui/app/serializers/volume.js @@ -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)); + hash.ReadAllocations = []; + hash.WriteAllocations = []; + + if (hash.Allocations) { + 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);