Skip to content

Commit

Permalink
fix discovery batch loading (#1632)
Browse files Browse the repository at this point in the history
* fix discovery batch loading

* fix return as needed
  • Loading branch information
mfshao authored Nov 8, 2024
1 parent 54a2b0a commit 31e2bd8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Discovery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,25 @@ const DiscoveryWithMDSBackend: React.FC<{

useEffect(() => {
// Update the numberOfBatchesLoaded to enable calling of different batch sizes with different parameters
if (numberOfBatchesLoaded < expectedNumberOfTotalBatches) setNumberOfBatchesLoaded(numberOfBatchesLoaded + 1);
if (numberOfBatchesLoaded < expectedNumberOfTotalBatches) {
setNumberOfBatchesLoaded(numberOfBatchesLoaded + 1);
} else {
return;
}

const studyRegistrationValidationField = studyRegistrationConfig?.studyRegistrationValidationField;
async function fetchRawStudies() {
let loadStudiesFunction: Function;
let loadStudiesParameters: any[] = [];
if (isEnabled('discoveryUseAggMDS')) {
loadStudiesFunction = loadStudiesFromAggMDS;
loadStudiesParameters.push(numberOfBatchesLoaded === 1
loadStudiesParameters.push(numberOfBatchesLoaded === 0
? numberOfStudiesForSmallerBatch
: numberOfStudiesForAllStudiesBatch);
} else {
loadStudiesFunction = loadStudiesFromMDS;
loadStudiesParameters = [props.config?.features?.guidType, 10, false];
loadStudiesParameters = (numberOfBatchesLoaded === 0
? [props.config?.features?.guidType, 10, false] : [props.config?.features?.guidType, 2000, true]);
}
const rawStudiesRegistered = await loadStudiesFunction(
...loadStudiesParameters,
Expand All @@ -109,7 +114,7 @@ const DiscoveryWithMDSBackend: React.FC<{
if (isEnabled('studyRegistration')) {
// Load fewer raw studies if on the first studies batch
// Otherwise load them all
rawStudiesUnregistered = numberOfBatchesLoaded === 1
rawStudiesUnregistered = numberOfBatchesLoaded === 0
? (rawStudiesUnregistered = await loadStudiesFromMDS(
'unregistered_discovery_metadata',
numberOfStudiesForSmallerBatch,
Expand Down

0 comments on commit 31e2bd8

Please sign in to comment.