From 2ea405967a6e98ad85b509af25f5a249e6ba5b1c Mon Sep 17 00:00:00 2001 From: TESTELIN Geoffrey Date: Wed, 2 Jun 2021 21:49:08 +0200 Subject: [PATCH] fix(operations): fail fast the current batch to respect the operations limit Instead of processing an entire batch of 100 issues before checking the operations left, simply do it before processing an issue so that we respect as expected the limitation of the operations per run Fixes #466 --- dist/index.js | 4 ++++ src/classes/issues-processor.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/dist/index.js b/dist/index.js index 6abefe920..316ec729c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -300,6 +300,10 @@ class IssuesProcessor { this._logger.info(chalk_1.default.yellow(`Processing the batch of issues ${chalk_1.default.cyan(`#${page}`)} containing ${chalk_1.default.cyan(issues.length)} issue${issues.length > 1 ? 's' : ''}...`)); } for (const issue of issues.values()) { + // Stop the processing if no more operations remains + if (!this._operations.hasRemainingOperations()) { + break; + } const issueLogger = new issue_logger_1.IssueLogger(issue); (_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementProcessedItemsCount(issue); issueLogger.info(`Found this $$type last updated at: ${chalk_1.default.cyan(issue.updated_at)}`); diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 6c951bab4..0c7950e95 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -117,6 +117,11 @@ export class IssuesProcessor { } for (const issue of issues.values()) { + // Stop the processing if no more operations remains + if (!this.operations.hasRemainingOperations()) { + break; + } + const issueLogger: IssueLogger = new IssueLogger(issue); this._statistics?.incrementProcessedItemsCount(issue);