From 6e01d910979149534a6cc90c1ddf9814178eec83 Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Tue, 26 May 2020 09:13:49 -0400 Subject: [PATCH] Fix operation counting --- dist/index.js | 10 ++++------ src/IssueProcessor.ts | 13 +++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index 095a8cf1..9431ad2b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8471,10 +8471,6 @@ class IssueProcessor { } processIssues(page = 1) { return __awaiter(this, void 0, void 0, function* () { - if (this.operationsLeft <= 0) { - core.warning('Reached max number of operations to process. Exiting.'); - return 0; - } // get the next batch of issues const issues = yield this.getIssues(page); this.operationsLeft -= 1; @@ -8518,7 +8514,6 @@ class IssueProcessor { if (!isStale && shouldBeStale) { core.info(`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`); yield this.markStale(issue, staleMessage, staleLabel); - this.operationsLeft -= 2; isStale = true; // this issue is now considered stale } // process the issue if it was marked stale @@ -8527,6 +8522,10 @@ class IssueProcessor { yield this.processStaleIssue(issue, issueType, staleLabel); } } + if (this.operationsLeft <= 0) { + core.warning('Reached max number of operations to process. Exiting.'); + return 0; + } // do the next batch return this.processIssues(page + 1); }); @@ -8566,7 +8565,6 @@ class IssueProcessor { if (!sinceDate) { return true; } - this.operationsLeft -= 1; // find any comments since the date const comments = yield this.listIssueComments(issue.number, sinceDate); const filteredComments = comments.filter(comment => comment.user.type === 'User' && diff --git a/src/IssueProcessor.ts b/src/IssueProcessor.ts index 7aad34fa..f54e96f6 100644 --- a/src/IssueProcessor.ts +++ b/src/IssueProcessor.ts @@ -97,11 +97,6 @@ export class IssueProcessor { } async processIssues(page: number = 1): Promise { - if (this.operationsLeft <= 0) { - core.warning('Reached max number of operations to process. Exiting.'); - return 0; - } - // get the next batch of issues const issues: Issue[] = await this.getIssues(page); this.operationsLeft -= 1; @@ -169,7 +164,6 @@ export class IssueProcessor { `Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label` ); await this.markStale(issue, staleMessage, staleLabel); - this.operationsLeft -= 2; isStale = true; // this issue is now considered stale } @@ -180,6 +174,11 @@ export class IssueProcessor { } } + if (this.operationsLeft <= 0) { + core.warning('Reached max number of operations to process. Exiting.'); + return 0; + } + // do the next batch return this.processIssues(page + 1); } @@ -246,8 +245,6 @@ export class IssueProcessor { return true; } - this.operationsLeft -= 1; - // find any comments since the date const comments = await this.listIssueComments(issue.number, sinceDate);