Fix operation counting

This commit is contained in:
Ross Brodbeck 2020-05-26 09:13:49 -04:00
parent 55ac880ddb
commit 6e01d91097
2 changed files with 9 additions and 14 deletions

10
dist/index.js vendored
View File

@ -8471,10 +8471,6 @@ class IssueProcessor {
} }
processIssues(page = 1) { processIssues(page = 1) {
return __awaiter(this, void 0, void 0, function* () { 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 // get the next batch of issues
const issues = yield this.getIssues(page); const issues = yield this.getIssues(page);
this.operationsLeft -= 1; this.operationsLeft -= 1;
@ -8518,7 +8514,6 @@ class IssueProcessor {
if (!isStale && shouldBeStale) { 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`); 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); yield this.markStale(issue, staleMessage, staleLabel);
this.operationsLeft -= 2;
isStale = true; // this issue is now considered stale isStale = true; // this issue is now considered stale
} }
// process the issue if it was marked stale // process the issue if it was marked stale
@ -8527,6 +8522,10 @@ class IssueProcessor {
yield this.processStaleIssue(issue, issueType, staleLabel); 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 // do the next batch
return this.processIssues(page + 1); return this.processIssues(page + 1);
}); });
@ -8566,7 +8565,6 @@ class IssueProcessor {
if (!sinceDate) { if (!sinceDate) {
return true; return true;
} }
this.operationsLeft -= 1;
// find any comments since the date // find any comments since the date
const comments = yield this.listIssueComments(issue.number, sinceDate); const comments = yield this.listIssueComments(issue.number, sinceDate);
const filteredComments = comments.filter(comment => comment.user.type === 'User' && const filteredComments = comments.filter(comment => comment.user.type === 'User' &&

View File

@ -97,11 +97,6 @@ export class IssueProcessor {
} }
async processIssues(page: number = 1): Promise<number> { async processIssues(page: number = 1): Promise<number> {
if (this.operationsLeft <= 0) {
core.warning('Reached max number of operations to process. Exiting.');
return 0;
}
// get the next batch of issues // get the next batch of issues
const issues: Issue[] = await this.getIssues(page); const issues: Issue[] = await this.getIssues(page);
this.operationsLeft -= 1; 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` `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); await this.markStale(issue, staleMessage, staleLabel);
this.operationsLeft -= 2;
isStale = true; // this issue is now considered stale 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 // do the next batch
return this.processIssues(page + 1); return this.processIssues(page + 1);
} }
@ -246,8 +245,6 @@ export class IssueProcessor {
return true; return true;
} }
this.operationsLeft -= 1;
// find any comments since the date // find any comments since the date
const comments = await this.listIssueComments(issue.number, sinceDate); const comments = await this.listIssueComments(issue.number, sinceDate);