Skip to content

Commit c279a1c

Browse files
committed
Update batch object and tests
1 parent 2f87b7b commit c279a1c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/batch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Batch {
1414
startedAt: BatchObject["startedAt"];
1515
finishedAt: BatchObject["finishedAt"];
1616
duration: BatchObject["duration"];
17+
progress: BatchObject["progress"];
1718

1819
constructor(batch: BatchObject) {
1920
this.uid = batch.uid;
@@ -22,6 +23,7 @@ class Batch {
2223
this.startedAt = batch.startedAt;
2324
this.finishedAt = batch.finishedAt;
2425
this.duration = batch.duration;
26+
this.progress = batch.progress;
2527
}
2628
}
2729

src/types/types.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,22 @@ export type BatchObject = {
697697
deletedDocuments?: number;
698698
};
699699

700-
/** Progress indicator (currently always null) */
701-
progress: null;
700+
/** Progress and indexing step of the batch, null if the batch is finished */
701+
progress: null | {
702+
/** An array of all the steps currently being processed */
703+
steps: Array<{
704+
/** A string representing the name of the current step
705+
* NOT stable. Only use for debugging purposes.
706+
*/
707+
currentStep: string;
708+
/** Number of finished tasks */
709+
finished: number;
710+
/** Total number of tasks to finish before moving to the next step */
711+
total: number;
712+
}>;
713+
/** Percentage of progression of all steps currently being processed*/
714+
percentage: number;
715+
};
702716

703717
/** Statistics about tasks within the batch */
704718
stats: {

tests/batch.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
4242
expect(batch.duration).toBeDefined();
4343
expect(batch.startedAt).toBeDefined();
4444
expect(batch.finishedAt).toBeDefined();
45+
expect(batch.progress).toBeDefined();
4546
});
4647
},
4748
);

0 commit comments

Comments
 (0)