Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify fetch resources from single study to multi-study #5038

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/pages/studyView/resources/FilesAndLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the js array natively has map on it so you don't need to wrap in lodash here. this might seem confusing given what i said last week but the real message is that we should strive to use the semantically accurate and descriptive method. if it's just map, then no reason to use lodash. the other reason to use lodash is it's support for chaining, but we're not doing that here.

Copy link
Contributor Author

@hweej hweej Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay no problem I can change to the native map. I was just going off of what the previous author did in another function in this same file.

.map(studyId =>
internalClient.getAllStudyResourceDataInStudyPatientSampleUsingGET({
studyId: studyId,
projection: 'DETAILED',
})
)
.value();

return Promise.all(allResources).then(allResources =>
_(allResources)
.flatMap()
.value()
);
return allResources;
}

function getResourceDataOfPatients(studyClinicalData: {
Expand Down
Loading