Skip to content

Commit

Permalink
Add config for how many submissions should be posted at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Mar 10, 2023
1 parent 3ea793d commit 15152b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/evaluator/configRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ export class ConfigRunner {
baseUrl,
apiToken,
uuid: configId,
regFormSubmissionChunks: facilityProcessingChunks
regFormSubmissionChunks: facilityProcessingChunks,
editSubmissionChunks: facilityEditChunks
} = config;
const regFormSubmissionChunks = facilityProcessingChunks ?? 1000;
const editSubmissionsChunks = facilityEditChunks ?? 100;

const startTime = Date.now();
const createMetric = createMetricFactory(startTime, configId);
Expand Down Expand Up @@ -127,11 +129,10 @@ export class ConfigRunner {
);

let cursor = 0;
const postChunks = 100;
while (cursor <= updateRegFormSubmissionsPromises.length) {
const end = cursor + postChunks;
const end = cursor + editSubmissionsChunks;
const chunksToSend = updateRegFormSubmissionsPromises.slice(cursor, end);
cursor = cursor + postChunks;
cursor = cursor + editSubmissionsChunks;
await Promise.allSettled(chunksToSend.map((x) => x()));
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export interface Config {
schedule: CronTabString;
// how many registration form submissions to process at a time.
regFormSubmissionChunks?: number;
// out of regFormSubmissionChunk how many should be posted/edited at a time
editSubmissionChunks?: number;
// store metric; progress information regarding a running pipeline or the last run of an pipeline
writeMetric: WriteMetric;
}
Expand Down

0 comments on commit 15152b6

Please sign in to comment.