Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix per issue operation count #662

Merged
merged 2 commits into from Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/classes/issues-processor-mock.ts
Expand Up @@ -9,7 +9,7 @@ export class IssuesProcessorMock extends IssuesProcessor {
options: IIssuesProcessorOptions,
getIssues?: (page: number) => Promise<Issue[]>,
listIssueComments?: (
issueNumber: number,
issue: Issue,
sinceDate: string
) => Promise<IComment[]>,
getLabelCreationDate?: (
Expand Down
10 changes: 5 additions & 5 deletions dist/index.js
Expand Up @@ -613,17 +613,17 @@ class IssuesProcessor {
});
}
// Grab comments for an issue since a given date
listIssueComments(issueNumber, sinceDate) {
listIssueComments(issue, sinceDate) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
// Find any comments since date on the given issue
try {
this.operations.consumeOperation();
this._consumeIssueOperation(issue);
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCommentsCount();
const comments = yield this.client.issues.listComments({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
issue_number: issueNumber,
issue_number: issue.number,
since: sinceDate
});
return comments.data;
Expand Down Expand Up @@ -763,7 +763,7 @@ class IssuesProcessor {
return true;
}
// find any comments since the date
const comments = yield this.listIssueComments(issue.number, sinceDate);
const comments = yield this.listIssueComments(issue, sinceDate);
const filteredComments = comments.filter(comment => comment.user.type === 'User' &&
comment.body.toLowerCase() !== staleMessage.toLowerCase());
issueLogger.info(`Comments that are not the stale comment or another bot: ${logger_service_1.LoggerService.cyan(filteredComments.length)}`);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ class IssuesProcessor {
issueLogger.info(`Adding all the labels specified via the ${this._logger.createOptionLink(option_1.Option.LabelsToAddWhenUnstale)} option.`);
this.addedLabelIssues.push(issue);
try {
this.operations.consumeOperation();
this._consumeIssueOperation(issue);
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) {
yield this.client.issues.addLabels({
Expand Down
10 changes: 5 additions & 5 deletions src/classes/issues-processor.ts
Expand Up @@ -510,17 +510,17 @@ export class IssuesProcessor {

// Grab comments for an issue since a given date
async listIssueComments(
issueNumber: Readonly<number>,
issue: Readonly<Issue>,
sinceDate: Readonly<string>
): Promise<IComment[]> {
// Find any comments since date on the given issue
try {
this.operations.consumeOperation();
this._consumeIssueOperation(issue);
this.statistics?.incrementFetchedItemsCommentsCount();
const comments = await this.client.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
issue_number: issue.number,
since: sinceDate
});
return comments.data;
Expand Down Expand Up @@ -734,7 +734,7 @@ export class IssuesProcessor {
}

// find any comments since the date
const comments = await this.listIssueComments(issue.number, sinceDate);
const comments = await this.listIssueComments(issue, sinceDate);

const filteredComments = comments.filter(
comment =>
Expand Down Expand Up @@ -1065,7 +1065,7 @@ export class IssuesProcessor {
this.addedLabelIssues.push(issue);

try {
this.operations.consumeOperation();
this._consumeIssueOperation(issue);
this.statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) {
await this.client.issues.addLabels({
Expand Down