Skip to content

Commit

Permalink
Refactor partition bounds logic
Browse files Browse the repository at this point in the history
Jira ticket: CAMS-421
  • Loading branch information
btposey committed Feb 10, 2025
1 parent 50c01e5 commit 967264a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions backend/function-apps/dataflows/import/migrate-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ function* partitionCaseIds(context: OrchestrationContext) {

const nextTasks: df.Task[] = [];
const partitionSize = 10000;
const partitionCount = Math.ceil(count / partitionSize);
for (let i = 0; i < partitionCount; i++) {
const childId = context.df.instanceId + `:${MIGRATE_CASES}:partition:${i}`;
const start = i * partitionSize;
const end = i * partitionSize + partitionSize;

let start = 0;
let end = 0;
let partitionCount = 0;

while (end < count) {
partitionCount += 1;
start = end + 1;
end += partitionSize;
const childId = context.df.instanceId + `:${MIGRATE_CASES}:partition:${partitionCount}`;
nextTasks.push(context.df.callSubOrchestrator(MIGRATE_PARTITION, { start, end }, childId));
}

Expand Down

0 comments on commit 967264a

Please sign in to comment.