From 0a2ee95c8e7e99791cf77f8085c924e79b4811d8 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 | 6 +++++- src/classes/issues-processor.ts | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index c0de1d825..f8e3376b9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -297,6 +297,10 @@ class IssuesProcessor { this._logger.info(`${logger_service_1.LoggerService.yellow('Processing the batch of issues')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.yellow('containing')} ${logger_service_1.LoggerService.cyan(issues.length)} ${logger_service_1.LoggerService.yellow(`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: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`); @@ -8866,4 +8870,4 @@ module.exports = require("zlib");; /******/ // Load entry module and return exports /******/ return __nccwpck_require__(3109); /******/ })() -; \ No newline at end of file +; diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 0706ec7d6..f8066dd53 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -121,6 +121,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);