From 108190810efcae21e788431bf04a0044b7b2ef48 Mon Sep 17 00:00:00 2001 From: Jason Hwee <1216418+hweej@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:03:27 -0500 Subject: [PATCH] Modify fetch resources from single study to multi-study (#5038) * Modify fetch resources from single study to multi-study * Switch usage of lodash to native map --- src/pages/studyView/resources/FilesAndLinks.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/studyView/resources/FilesAndLinks.tsx b/src/pages/studyView/resources/FilesAndLinks.tsx index bc619c96984..0476590efe8 100644 --- a/src/pages/studyView/resources/FilesAndLinks.tsx +++ b/src/pages/studyView/resources/FilesAndLinks.tsx @@ -34,16 +34,19 @@ class FilesLinksTableComponent extends LazyMobXTable<{ const RECORD_LIMIT = 500; function getResourceDataOfEntireStudy(studyIds: string[]) { - // Only handle the first studyId for now. Can be expanded to make a call per - // studyId. - const studyId = studyIds[0]; - const allResources = internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET( - { + // Fetch resource data for each studyId, then return combined results + const allResources = studyIds.map(studyId => + internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET({ studyId: studyId, projection: 'DETAILED', - } + }) + ); + + return Promise.all(allResources).then(allResources => + _(allResources) + .flatMap() + .value() ); - return allResources; } function getResourceDataOfPatients(studyClinicalData: {