From 6ea0c60e3821cb2f1c643b5daeecae5af1491329 Mon Sep 17 00:00:00 2001 From: Jason Hwee <1216418+hweej@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:11:25 -0500 Subject: [PATCH 1/2] Modify fetch resources from single study to multi-study --- .../studyView/resources/FilesAndLinks.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/pages/studyView/resources/FilesAndLinks.tsx b/src/pages/studyView/resources/FilesAndLinks.tsx index bc619c96984..e3f094eedfb 100644 --- a/src/pages/studyView/resources/FilesAndLinks.tsx +++ b/src/pages/studyView/resources/FilesAndLinks.tsx @@ -34,16 +34,21 @@ 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( - { - studyId: studyId, - projection: 'DETAILED', - } + // Fetch resource data for each studyId, then return combined results + const allResources = _(studyIds) + .map(studyId => + internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET({ + studyId: studyId, + projection: 'DETAILED', + }) + ) + .value(); + + return Promise.all(allResources).then(allResources => + _(allResources) + .flatMap() + .value() ); - return allResources; } function getResourceDataOfPatients(studyClinicalData: { From c15e61e4bccfb4db216247343fb6c71977b1a528 Mon Sep 17 00:00:00 2001 From: Jason Hwee <1216418+hweej@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:41:47 -0500 Subject: [PATCH 2/2] Switch usage of lodash to native map --- src/pages/studyView/resources/FilesAndLinks.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/studyView/resources/FilesAndLinks.tsx b/src/pages/studyView/resources/FilesAndLinks.tsx index e3f094eedfb..0476590efe8 100644 --- a/src/pages/studyView/resources/FilesAndLinks.tsx +++ b/src/pages/studyView/resources/FilesAndLinks.tsx @@ -35,14 +35,12 @@ const RECORD_LIMIT = 500; function getResourceDataOfEntireStudy(studyIds: string[]) { // Fetch resource data for each studyId, then return combined results - const allResources = _(studyIds) - .map(studyId => - internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET({ - studyId: studyId, - projection: 'DETAILED', - }) - ) - .value(); + const allResources = studyIds.map(studyId => + internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET({ + studyId: studyId, + projection: 'DETAILED', + }) + ); return Promise.all(allResources).then(allResources => _(allResources)