Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed May 16, 2024
1 parent eaadfe6 commit 48f3317
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/generate-job.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ writeFileSync(
JSON.stringify({
id: "test-" + crypto.randomUUID(),
displayName: "Test Job",
tasks: Array.from({ length: 500 }, (_, i) => ({
tasks: Array.from({ length: 200 }, (_, i) => ({
id: `task-${i}`,
displayName: `Task ${i}`,
})),
Expand Down
13 changes: 9 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ yargs(process.argv.slice(2))

const queueUrl = await ensureQueueCreated(ctx, job.id);
const statuses = await getPreviouslyRunTaskStatuses(ctx, job.id);

const statusItems = statuses.Items ?? [];
console.log("Number of tasks previously run:", statusItems.length);

const completedTaskIds = new Set(
statusItems
.filter((item) => item.Status.S === "COMPLETED")
.map((item) => item.TaskId.S)
);
console.log("Number of tasks already completed:", completedTaskIds.size);

const tasksToEnqueue = job.tasks.filter(
(task) =>
!statusItems.find(
(item) => item.TaskId.S === task.id && item.Status.S === "COMPLETED"
)
(task) => !completedTaskIds.has(task.id)
);
console.log("Number of tasks to enqueue:", tasksToEnqueue.length);

Expand Down

0 comments on commit 48f3317

Please sign in to comment.