docs(stale-issue-comment): update the docs to remove that omitting the option will not send a message (#522)

* chore(assignees): add logs

* docs(stale-issue-comment): update the docs to remove that omitting will not send a message

To be sure, what would be even better is to add a test using the default config (because the main issue is that the default options of the specs are not matching the ones from the action).

Closes #521

* test(comment): add more coverage to test the stale issue message

* docs(readme): improve the wording

Co-authored-by: Luke Tomlinson <luketomlinson@github.com>

* refactor: simplify the code to use the stats for the specs

* chore(rebase): fix rebase issue

* chore(statistics): fix issue due to rebase

Co-authored-by: Luke Tomlinson <luketomlinson@github.com>
This commit is contained in:
Geoffrey Testelin 2021-09-22 15:18:19 +02:00 committed by GitHub
parent 9912fa74d1
commit b98591d49e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 258 additions and 176 deletions

View File

@ -4,7 +4,7 @@ Warns and then closes issues and PRs that have had no activity for a specified a
The configuration must be on the default branch and the default values will: The configuration must be on the default branch and the default values will:
- Add a label "Stale" on issues and pull requests after 60 days of inactivity - Add a label "Stale" on issues and pull requests after 60 days of inactivity and comment on them
- Close the stale issues and pull requests after 7 days of inactivity - Close the stale issues and pull requests after 7 days of inactivity
- If an update/comment occur on stale issues or pull requests, the stale label will be removed and the timer will restart - If an update/comment occur on stale issues or pull requests, the stale label will be removed and the timer will restart
@ -175,7 +175,7 @@ Default value: unset
The message that will be added as a comment to the issues when the stale workflow marks it automatically as stale with a label. The message that will be added as a comment to the issues when the stale workflow marks it automatically as stale with a label.
You can skip the comment sending by omitting the option or by passing an empty string. You can skip the comment sending by passing an empty string.
Default value: unset Default value: unset
Required Permission: `issues: write` Required Permission: `issues: write`
@ -184,7 +184,7 @@ Required Permission: `issues: write`
The message that will be added as a comment to the pull requests when the stale workflow marks it automatically as stale with a label. The message that will be added as a comment to the pull requests when the stale workflow marks it automatically as stale with a label.
You can skip the comment sending by omitting the option or by passing an empty string. You can skip the comment sending by passing an empty string.
Default value: unset Default value: unset
Required Permission: `pull-requests: write` Required Permission: `pull-requests: write`

View File

@ -2282,3 +2282,73 @@ test('processing an issue stale since less than the daysBeforeStale without a st
expect(processor.deletedBranchIssues).toHaveLength(0); expect(processor.deletedBranchIssues).toHaveLength(0);
expect(processor.closedIssues).toHaveLength(0); expect(processor.closedIssues).toHaveLength(0);
}); });
test('processing a pull request to be stale with the "stalePrMessage" option set will send a PR comment', async () => {
expect.assertions(3);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
stalePrMessage: 'This PR is stale',
daysBeforeStale: 10,
daysBeforePrStale: 1
};
const issueDate = new Date();
issueDate.setDate(issueDate.getDate() - 2);
const TestIssueList: Issue[] = [
generateIssue(
opts,
1,
'A pull request with no label and a stale message',
issueDate.toDateString(),
issueDate.toDateString(),
true
)
];
const processor = new IssuesProcessorMock(
opts,
async p => (p === 1 ? TestIssueList : []),
async () => [],
async () => new Date().toDateString()
);
// process our fake issue list
await processor.processIssues(1);
expect(processor.staleIssues).toHaveLength(1);
expect(processor.closedIssues).toHaveLength(0);
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(1);
});
test('processing a pull request to be stale with the "stalePrMessage" option set to empty will not send a PR comment', async () => {
expect.assertions(3);
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
stalePrMessage: '',
daysBeforeStale: 10,
daysBeforePrStale: 1
};
const issueDate = new Date();
issueDate.setDate(issueDate.getDate() - 2);
const TestIssueList: Issue[] = [
generateIssue(
opts,
1,
'A pull request with no label and a stale message',
issueDate.toDateString(),
issueDate.toDateString(),
true
)
];
const processor = new IssuesProcessorMock(
opts,
async p => (p === 1 ? TestIssueList : []),
async () => [],
async () => new Date().toDateString()
);
// process our fake issue list
await processor.processIssues(1);
expect(processor.staleIssues).toHaveLength(1);
expect(processor.closedIssues).toHaveLength(0);
expect(processor.statistics?.addedPullRequestsCommentsCount).toStrictEqual(0);
});

178
dist/index.js vendored
View File

@ -365,6 +365,7 @@ class IssuesProcessor {
this.deletedBranchIssues = []; this.deletedBranchIssues = [];
this.removedLabelIssues = []; this.removedLabelIssues = [];
this.addedLabelIssues = []; this.addedLabelIssues = [];
this.addedCloseCommentIssues = [];
this._logger = new logger_1.Logger(); this._logger = new logger_1.Logger();
this.options = options; this.options = options;
this.client = github_1.getOctokit(this.options.repoToken); this.client = github_1.getOctokit(this.options.repoToken);
@ -375,7 +376,7 @@ class IssuesProcessor {
this._logger.warning(logger_service_1.LoggerService.yellowBright(`The debug output will be written but no issues/PRs will be processed.`)); this._logger.warning(logger_service_1.LoggerService.yellowBright(`The debug output will be written but no issues/PRs will be processed.`));
} }
if (this.options.enableStatistics) { if (this.options.enableStatistics) {
this._statistics = new statistics_1.Statistics(); this.statistics = new statistics_1.Statistics();
} }
} }
static _updatedSince(timestamp, num_days) { static _updatedSince(timestamp, num_days) {
@ -400,7 +401,7 @@ class IssuesProcessor {
const issues = yield this.getIssues(page); const issues = yield this.getIssues(page);
if (issues.length <= 0) { if (issues.length <= 0) {
this._logger.info(logger_service_1.LoggerService.green(`No more issues found to process. Exiting...`)); this._logger.info(logger_service_1.LoggerService.green(`No more issues found to process. Exiting...`));
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats(); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats();
return this.operations.getRemainingOperationsCount(); return this.operations.getRemainingOperationsCount();
} }
else { else {
@ -421,7 +422,7 @@ class IssuesProcessor {
if (!this.operations.hasRemainingOperations()) { if (!this.operations.hasRemainingOperations()) {
this._logger.warning(logger_service_1.LoggerService.yellowBright(`No more operations left! Exiting...`)); this._logger.warning(logger_service_1.LoggerService.yellowBright(`No more operations left! Exiting...`));
this._logger.warning(`${logger_service_1.LoggerService.yellowBright('If you think that not enough issues were processed you could try to increase the quantity related to the')} ${this._logger.createOptionLink(option_1.Option.OperationsPerRun)} ${logger_service_1.LoggerService.yellowBright('option which is currently set to')} ${logger_service_1.LoggerService.cyan(this.options.operationsPerRun)}`); this._logger.warning(`${logger_service_1.LoggerService.yellowBright('If you think that not enough issues were processed you could try to increase the quantity related to the')} ${this._logger.createOptionLink(option_1.Option.OperationsPerRun)} ${logger_service_1.LoggerService.yellowBright('option which is currently set to')} ${logger_service_1.LoggerService.cyan(this.options.operationsPerRun)}`);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats(); (_b = this.statistics) === null || _b === void 0 ? void 0 : _b.setOperationsCount(this.operations.getConsumedOperationsCount()).logStats();
return 0; return 0;
} }
this._logger.info(`${logger_service_1.LoggerService.green('Batch')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.green('processed.')}`); this._logger.info(`${logger_service_1.LoggerService.green('Batch')} ${logger_service_1.LoggerService.cyan(`#${page}`)} ${logger_service_1.LoggerService.green('processed.')}`);
@ -432,7 +433,7 @@ class IssuesProcessor {
processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale) { processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale) {
var _a; var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue);
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Found this $$type last updated at: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`); issueLogger.info(`Found this $$type last updated at: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`);
// calculate string based messages for this issue // calculate string based messages for this issue
@ -618,7 +619,7 @@ class IssuesProcessor {
// Find any comments since date on the given issue // Find any comments since date on the given issue
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCommentsCount(); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCommentsCount();
const comments = yield this.client.issues.listComments({ const comments = yield this.client.issues.listComments({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@ -649,7 +650,7 @@ class IssuesProcessor {
direction: this.options.ascending ? 'asc' : 'desc', direction: this.options.ascending ? 'asc' : 'desc',
page page
}); });
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCount(issueResult.data.length); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCount(issueResult.data.length);
return issueResult.data.map((issue) => new issue_1.Issue(this.options, issue)); return issueResult.data.map((issue) => new issue_1.Issue(this.options, issue));
} }
catch (error) { catch (error) {
@ -666,7 +667,7 @@ class IssuesProcessor {
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Checking for label on this $$type`); issueLogger.info(`Checking for label on this $$type`);
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount(); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount();
const options = this.client.issues.listEvents.endpoint.merge({ const options = this.client.issues.listEvents.endpoint.merge({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@ -690,7 +691,7 @@ class IssuesProcessor {
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount(); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount();
const pullRequest = yield this.client.pulls.get({ const pullRequest = yield this.client.pulls.get({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@ -784,7 +785,7 @@ class IssuesProcessor {
if (!skipMessage) { if (!skipMessage) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.createComment({ yield this.client.issues.createComment({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -800,8 +801,8 @@ class IssuesProcessor {
} }
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue); (_b = this.statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue);
(_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue); (_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.addLabels({ yield this.client.issues.addLabels({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -826,7 +827,8 @@ class IssuesProcessor {
if (closeMessage) { if (closeMessage) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue);
this.addedCloseCommentIssues.push(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.createComment({ yield this.client.issues.createComment({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -843,7 +845,7 @@ class IssuesProcessor {
if (closeLabel) { if (closeLabel) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue); (_b = this.statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.addLabels({ yield this.client.issues.addLabels({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -859,7 +861,7 @@ class IssuesProcessor {
} }
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue); (_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.update({ yield this.client.issues.update({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -879,7 +881,11 @@ class IssuesProcessor {
var _a; var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Delete branch from closed $$type - ${issue.title}`); issueLogger.info(`Delete
branch from closed $
$type
-
${issue.title}`);
const pullRequest = yield this.getPullRequest(issue); const pullRequest = yield this.getPullRequest(issue);
if (!pullRequest) { if (!pullRequest) {
issueLogger.info(`Not deleting this branch as no pull request was found for this $$type`); issueLogger.info(`Not deleting this branch as no pull request was found for this $$type`);
@ -889,7 +895,7 @@ class IssuesProcessor {
issueLogger.info(`Deleting the branch "${logger_service_1.LoggerService.cyan(branch)}" from closed $$type`); issueLogger.info(`Deleting the branch "${logger_service_1.LoggerService.cyan(branch)}" from closed $$type`);
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedBranchesCount(); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedBranchesCount();
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.git.deleteRef({ yield this.client.git.deleteRef({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -912,7 +918,7 @@ class IssuesProcessor {
this.removedLabelIssues.push(issue); this.removedLabelIssues.push(issue);
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedItemsLabelsCount(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedItemsLabelsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.removeLabel({ yield this.client.issues.removeLabel({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -1009,7 +1015,7 @@ class IssuesProcessor {
this.addedLabelIssues.push(issue); this.addedLabelIssues.push(issue);
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
yield this.client.issues.addLabels({ yield this.client.issues.addLabels({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
@ -1030,7 +1036,7 @@ class IssuesProcessor {
const issueLogger = new issue_logger_1.IssueLogger(issue); const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`The $$type is no longer stale. Removing the stale label...`); issueLogger.info(`The $$type is no longer stale. Removing the stale label...`);
yield this._removeLabel(issue, staleLabel); yield this._removeLabel(issue, staleLabel);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementUndoStaleItemsCount(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementUndoStaleItemsCount(issue);
}); });
} }
_removeCloseLabel(issue, closeLabel) { _removeCloseLabel(issue, closeLabel) {
@ -1046,7 +1052,7 @@ class IssuesProcessor {
if (is_labeled_1.isLabeled(issue, closeLabel)) { if (is_labeled_1.isLabeled(issue, closeLabel)) {
issueLogger.info(logger_service_1.LoggerService.white('├──'), `The $$type has a close label "${logger_service_1.LoggerService.cyan(closeLabel)}". Removing the close label...`); issueLogger.info(logger_service_1.LoggerService.white('├──'), `The $$type has a close label "${logger_service_1.LoggerService.cyan(closeLabel)}". Removing the close label...`);
yield this._removeLabel(issue, closeLabel, true); yield this._removeLabel(issue, closeLabel, true);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedCloseItemsLabelsCount(issue); (_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedCloseItemsLabelsCount(issue);
} }
else { else {
issueLogger.info(logger_service_1.LoggerService.white('└──'), `There is no close label on this $$type. Skipping`); issueLogger.info(logger_service_1.LoggerService.white('└──'), `There is no close label on this $$type. Skipping`);
@ -1457,28 +1463,28 @@ const logger_service_1 = __nccwpck_require__(1973);
class Statistics { class Statistics {
constructor() { constructor() {
this._logger = new logger_1.Logger(); this._logger = new logger_1.Logger();
this._processedIssuesCount = 0; this.processedIssuesCount = 0;
this._processedPullRequestsCount = 0; this.processedPullRequestsCount = 0;
this._staleIssuesCount = 0; this.staleIssuesCount = 0;
this._stalePullRequestsCount = 0; this.stalePullRequestsCount = 0;
this._undoStaleIssuesCount = 0; this.undoStaleIssuesCount = 0;
this._undoStalePullRequestsCount = 0; this.undoStalePullRequestsCount = 0;
this._operationsCount = 0; this.operationsCount = 0;
this._closedIssuesCount = 0; this.closedIssuesCount = 0;
this._closedPullRequestsCount = 0; this.closedPullRequestsCount = 0;
this._deletedIssuesLabelsCount = 0; this.deletedIssuesLabelsCount = 0;
this._deletedPullRequestsLabelsCount = 0; this.deletedPullRequestsLabelsCount = 0;
this._deletedCloseIssuesLabelsCount = 0; this.deletedCloseIssuesLabelsCount = 0;
this._deletedClosePullRequestsLabelsCount = 0; this.deletedClosePullRequestsLabelsCount = 0;
this._deletedBranchesCount = 0; this.deletedBranchesCount = 0;
this._addedIssuesLabelsCount = 0; this.addedIssuesLabelsCount = 0;
this._addedPullRequestsLabelsCount = 0; this.addedPullRequestsLabelsCount = 0;
this._addedIssuesCommentsCount = 0; this.addedIssuesCommentsCount = 0;
this._addedPullRequestsCommentsCount = 0; this.addedPullRequestsCommentsCount = 0;
this._fetchedItemsCount = 0; this.fetchedItemsCount = 0;
this._fetchedItemsEventsCount = 0; this.fetchedItemsEventsCount = 0;
this._fetchedItemsCommentsCount = 0; this.fetchedItemsCommentsCount = 0;
this._fetchedPullRequestsCount = 0; this.fetchedPullRequestsCount = 0;
} }
incrementProcessedItemsCount(issue, increment = 1) { incrementProcessedItemsCount(issue, increment = 1) {
if (issue.isPullRequest) { if (issue.isPullRequest) {
@ -1499,7 +1505,7 @@ class Statistics {
return this._incrementUndoStaleIssuesCount(increment); return this._incrementUndoStaleIssuesCount(increment);
} }
setOperationsCount(operationsCount) { setOperationsCount(operationsCount) {
this._operationsCount = operationsCount; this.operationsCount = operationsCount;
return this; return this;
} }
incrementClosedItemsCount(issue, increment = 1) { incrementClosedItemsCount(issue, increment = 1) {
@ -1521,7 +1527,7 @@ class Statistics {
return this._incrementDeletedCloseIssuesLabelsCount(increment); return this._incrementDeletedCloseIssuesLabelsCount(increment);
} }
incrementDeletedBranchesCount(increment = 1) { incrementDeletedBranchesCount(increment = 1) {
this._deletedBranchesCount += increment; this.deletedBranchesCount += increment;
return this; return this;
} }
incrementAddedItemsLabel(issue, increment = 1) { incrementAddedItemsLabel(issue, increment = 1) {
@ -1537,19 +1543,19 @@ class Statistics {
return this._incrementAddedIssuesComment(increment); return this._incrementAddedIssuesComment(increment);
} }
incrementFetchedItemsCount(increment = 1) { incrementFetchedItemsCount(increment = 1) {
this._fetchedItemsCount += increment; this.fetchedItemsCount += increment;
return this; return this;
} }
incrementFetchedItemsEventsCount(increment = 1) { incrementFetchedItemsEventsCount(increment = 1) {
this._fetchedItemsEventsCount += increment; this.fetchedItemsEventsCount += increment;
return this; return this;
} }
incrementFetchedItemsCommentsCount(increment = 1) { incrementFetchedItemsCommentsCount(increment = 1) {
this._fetchedItemsCommentsCount += increment; this.fetchedItemsCommentsCount += increment;
return this; return this;
} }
incrementFetchedPullRequestsCount(increment = 1) { incrementFetchedPullRequestsCount(increment = 1) {
this._fetchedPullRequestsCount += increment; this.fetchedPullRequestsCount += increment;
return this; return this;
} }
logStats() { logStats() {
@ -1571,78 +1577,78 @@ class Statistics {
return this; return this;
} }
_incrementProcessedIssuesCount(increment = 1) { _incrementProcessedIssuesCount(increment = 1) {
this._processedIssuesCount += increment; this.processedIssuesCount += increment;
return this; return this;
} }
_incrementProcessedPullRequestsCount(increment = 1) { _incrementProcessedPullRequestsCount(increment = 1) {
this._processedPullRequestsCount += increment; this.processedPullRequestsCount += increment;
return this; return this;
} }
_incrementStaleIssuesCount(increment = 1) { _incrementStaleIssuesCount(increment = 1) {
this._staleIssuesCount += increment; this.staleIssuesCount += increment;
return this; return this;
} }
_incrementStalePullRequestsCount(increment = 1) { _incrementStalePullRequestsCount(increment = 1) {
this._stalePullRequestsCount += increment; this.stalePullRequestsCount += increment;
return this; return this;
} }
_incrementUndoStaleIssuesCount(increment = 1) { _incrementUndoStaleIssuesCount(increment = 1) {
this._undoStaleIssuesCount += increment; this.undoStaleIssuesCount += increment;
return this; return this;
} }
_incrementUndoStalePullRequestsCount(increment = 1) { _incrementUndoStalePullRequestsCount(increment = 1) {
this._undoStalePullRequestsCount += increment; this.undoStalePullRequestsCount += increment;
return this; return this;
} }
_incrementClosedIssuesCount(increment = 1) { _incrementClosedIssuesCount(increment = 1) {
this._closedIssuesCount += increment; this.closedIssuesCount += increment;
return this; return this;
} }
_incrementClosedPullRequestsCount(increment = 1) { _incrementClosedPullRequestsCount(increment = 1) {
this._closedPullRequestsCount += increment; this.closedPullRequestsCount += increment;
return this; return this;
} }
_incrementDeletedIssuesLabelsCount(increment = 1) { _incrementDeletedIssuesLabelsCount(increment = 1) {
this._deletedIssuesLabelsCount += increment; this.deletedIssuesLabelsCount += increment;
return this; return this;
} }
_incrementDeletedPullRequestsLabelsCount(increment = 1) { _incrementDeletedPullRequestsLabelsCount(increment = 1) {
this._deletedPullRequestsLabelsCount += increment; this.deletedPullRequestsLabelsCount += increment;
return this; return this;
} }
_incrementDeletedCloseIssuesLabelsCount(increment = 1) { _incrementDeletedCloseIssuesLabelsCount(increment = 1) {
this._deletedCloseIssuesLabelsCount += increment; this.deletedCloseIssuesLabelsCount += increment;
return this; return this;
} }
_incrementDeletedClosePullRequestsLabelsCount(increment = 1) { _incrementDeletedClosePullRequestsLabelsCount(increment = 1) {
this._deletedClosePullRequestsLabelsCount += increment; this.deletedClosePullRequestsLabelsCount += increment;
return this; return this;
} }
_incrementAddedIssuesLabel(increment = 1) { _incrementAddedIssuesLabel(increment = 1) {
this._addedIssuesLabelsCount += increment; this.addedIssuesLabelsCount += increment;
return this; return this;
} }
_incrementAddedPullRequestsLabel(increment = 1) { _incrementAddedPullRequestsLabel(increment = 1) {
this._addedPullRequestsLabelsCount += increment; this.addedPullRequestsLabelsCount += increment;
return this; return this;
} }
_incrementAddedIssuesComment(increment = 1) { _incrementAddedIssuesComment(increment = 1) {
this._addedIssuesCommentsCount += increment; this.addedIssuesCommentsCount += increment;
return this; return this;
} }
_incrementAddedPullRequestsComment(increment = 1) { _incrementAddedPullRequestsComment(increment = 1) {
this._addedPullRequestsCommentsCount += increment; this.addedPullRequestsCommentsCount += increment;
return this; return this;
} }
_logProcessedIssuesAndPullRequestsCount() { _logProcessedIssuesAndPullRequestsCount() {
this._logGroup('Processed items', [ this._logGroup('Processed items', [
{ {
name: 'Processed issues', name: 'Processed issues',
count: this._processedIssuesCount count: this.processedIssuesCount
}, },
{ {
name: 'Processed PRs', name: 'Processed PRs',
count: this._processedPullRequestsCount count: this.processedPullRequestsCount
} }
]); ]);
} }
@ -1650,11 +1656,11 @@ class Statistics {
this._logGroup('New stale items', [ this._logGroup('New stale items', [
{ {
name: 'New stale issues', name: 'New stale issues',
count: this._staleIssuesCount count: this.staleIssuesCount
}, },
{ {
name: 'New stale PRs', name: 'New stale PRs',
count: this._stalePullRequestsCount count: this.stalePullRequestsCount
} }
]); ]);
} }
@ -1662,11 +1668,11 @@ class Statistics {
this._logGroup('No longer stale items', [ this._logGroup('No longer stale items', [
{ {
name: 'No longer stale issues', name: 'No longer stale issues',
count: this._undoStaleIssuesCount count: this.undoStaleIssuesCount
}, },
{ {
name: 'No longer stale PRs', name: 'No longer stale PRs',
count: this._undoStalePullRequestsCount count: this.undoStalePullRequestsCount
} }
]); ]);
} }
@ -1674,11 +1680,11 @@ class Statistics {
this._logGroup('Closed items', [ this._logGroup('Closed items', [
{ {
name: 'Closed issues', name: 'Closed issues',
count: this._closedIssuesCount count: this.closedIssuesCount
}, },
{ {
name: 'Closed PRs', name: 'Closed PRs',
count: this._closedPullRequestsCount count: this.closedPullRequestsCount
} }
]); ]);
} }
@ -1686,11 +1692,11 @@ class Statistics {
this._logGroup('Deleted items labels', [ this._logGroup('Deleted items labels', [
{ {
name: 'Deleted issues labels', name: 'Deleted issues labels',
count: this._deletedIssuesLabelsCount count: this.deletedIssuesLabelsCount
}, },
{ {
name: 'Deleted PRs labels', name: 'Deleted PRs labels',
count: this._deletedPullRequestsLabelsCount count: this.deletedPullRequestsLabelsCount
} }
]); ]);
} }
@ -1698,26 +1704,26 @@ class Statistics {
this._logGroup('Deleted close items labels', [ this._logGroup('Deleted close items labels', [
{ {
name: 'Deleted close issues labels', name: 'Deleted close issues labels',
count: this._deletedCloseIssuesLabelsCount count: this.deletedCloseIssuesLabelsCount
}, },
{ {
name: 'Deleted close PRs labels', name: 'Deleted close PRs labels',
count: this._deletedClosePullRequestsLabelsCount count: this.deletedClosePullRequestsLabelsCount
} }
]); ]);
} }
_logDeletedBranchesCount() { _logDeletedBranchesCount() {
this._logCount('Deleted branches', this._deletedBranchesCount); this._logCount('Deleted branches', this.deletedBranchesCount);
} }
_logAddedIssuesAndPullRequestsLabelsCount() { _logAddedIssuesAndPullRequestsLabelsCount() {
this._logGroup('Added items labels', [ this._logGroup('Added items labels', [
{ {
name: 'Added issues labels', name: 'Added issues labels',
count: this._addedIssuesLabelsCount count: this.addedIssuesLabelsCount
}, },
{ {
name: 'Added PRs labels', name: 'Added PRs labels',
count: this._addedPullRequestsLabelsCount count: this.addedPullRequestsLabelsCount
} }
]); ]);
} }
@ -1725,28 +1731,28 @@ class Statistics {
this._logGroup('Added items comments', [ this._logGroup('Added items comments', [
{ {
name: 'Added issues comments', name: 'Added issues comments',
count: this._addedIssuesCommentsCount count: this.addedIssuesCommentsCount
}, },
{ {
name: 'Added PRs comments', name: 'Added PRs comments',
count: this._addedPullRequestsCommentsCount count: this.addedPullRequestsCommentsCount
} }
]); ]);
} }
_logFetchedItemsCount() { _logFetchedItemsCount() {
this._logCount('Fetched items', this._fetchedItemsCount); this._logCount('Fetched items', this.fetchedItemsCount);
} }
_logFetchedItemsEventsCount() { _logFetchedItemsEventsCount() {
this._logCount('Fetched items events', this._fetchedItemsEventsCount); this._logCount('Fetched items events', this.fetchedItemsEventsCount);
} }
_logFetchedItemsCommentsCount() { _logFetchedItemsCommentsCount() {
this._logCount('Fetched items comments', this._fetchedItemsCommentsCount); this._logCount('Fetched items comments', this.fetchedItemsCommentsCount);
} }
_logFetchedPullRequestsCount() { _logFetchedPullRequestsCount() {
this._logCount('Fetched pull requests', this._fetchedPullRequestsCount); this._logCount('Fetched pull requests', this.fetchedPullRequestsCount);
} }
_logOperationsCount() { _logOperationsCount() {
this._logCount('Operations performed', this._operationsCount); this._logCount('Operations performed', this.operationsCount);
} }
_logCount(name, count) { _logCount(name, count) {
if (count > 0) { if (count > 0) {

View File

@ -69,8 +69,9 @@ export class IssuesProcessor {
readonly deletedBranchIssues: Issue[] = []; readonly deletedBranchIssues: Issue[] = [];
readonly removedLabelIssues: Issue[] = []; readonly removedLabelIssues: Issue[] = [];
readonly addedLabelIssues: Issue[] = []; readonly addedLabelIssues: Issue[] = [];
readonly addedCloseCommentIssues: Issue[] = [];
readonly statistics: Statistics | undefined;
private readonly _logger: Logger = new Logger(); private readonly _logger: Logger = new Logger();
private readonly _statistics: Statistics | undefined;
constructor(options: IIssuesProcessorOptions) { constructor(options: IIssuesProcessorOptions) {
this.options = options; this.options = options;
@ -93,7 +94,7 @@ export class IssuesProcessor {
} }
if (this.options.enableStatistics) { if (this.options.enableStatistics) {
this._statistics = new Statistics(); this.statistics = new Statistics();
} }
} }
@ -105,7 +106,7 @@ export class IssuesProcessor {
this._logger.info( this._logger.info(
LoggerService.green(`No more issues found to process. Exiting...`) LoggerService.green(`No more issues found to process. Exiting...`)
); );
this._statistics this.statistics
?.setOperationsCount(this.operations.getConsumedOperationsCount()) ?.setOperationsCount(this.operations.getConsumedOperationsCount())
.logStats(); .logStats();
@ -158,7 +159,7 @@ export class IssuesProcessor {
'option which is currently set to' 'option which is currently set to'
)} ${LoggerService.cyan(this.options.operationsPerRun)}` )} ${LoggerService.cyan(this.options.operationsPerRun)}`
); );
this._statistics this.statistics
?.setOperationsCount(this.operations.getConsumedOperationsCount()) ?.setOperationsCount(this.operations.getConsumedOperationsCount())
.logStats(); .logStats();
@ -180,7 +181,7 @@ export class IssuesProcessor {
labelsToAddWhenUnstale: Readonly<string>[], labelsToAddWhenUnstale: Readonly<string>[],
labelsToRemoveWhenUnstale: Readonly<string>[] labelsToRemoveWhenUnstale: Readonly<string>[]
): Promise<void> { ): Promise<void> {
this._statistics?.incrementProcessedItemsCount(issue); this.statistics?.incrementProcessedItemsCount(issue);
const issueLogger: IssueLogger = new IssueLogger(issue); const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info( issueLogger.info(
@ -515,7 +516,7 @@ export class IssuesProcessor {
// Find any comments since date on the given issue // Find any comments since date on the given issue
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
this._statistics?.incrementFetchedItemsCommentsCount(); this.statistics?.incrementFetchedItemsCommentsCount();
const comments = await this.client.issues.listComments({ const comments = await this.client.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@ -546,7 +547,7 @@ export class IssuesProcessor {
direction: this.options.ascending ? 'asc' : 'desc', direction: this.options.ascending ? 'asc' : 'desc',
page page
}); });
this._statistics?.incrementFetchedItemsCount(issueResult.data.length); this.statistics?.incrementFetchedItemsCount(issueResult.data.length);
return issueResult.data.map( return issueResult.data.map(
(issue: Readonly<IIssue>): Issue => new Issue(this.options, issue) (issue: Readonly<IIssue>): Issue => new Issue(this.options, issue)
@ -568,7 +569,7 @@ export class IssuesProcessor {
issueLogger.info(`Checking for label on this $$type`); issueLogger.info(`Checking for label on this $$type`);
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementFetchedItemsEventsCount(); this.statistics?.incrementFetchedItemsEventsCount();
const options = this.client.issues.listEvents.endpoint.merge({ const options = this.client.issues.listEvents.endpoint.merge({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@ -598,7 +599,7 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementFetchedPullRequestsCount(); this.statistics?.incrementFetchedPullRequestsCount();
const pullRequest = await this.client.pulls.get({ const pullRequest = await this.client.pulls.get({
owner: context.repo.owner, owner: context.repo.owner,
@ -771,7 +772,7 @@ export class IssuesProcessor {
if (!skipMessage) { if (!skipMessage) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsComment(issue); this.statistics?.incrementAddedItemsComment(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.createComment({ await this.client.issues.createComment({
@ -788,8 +789,8 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsLabel(issue); this.statistics?.incrementAddedItemsLabel(issue);
this._statistics?.incrementStaleItemsCount(issue); this.statistics?.incrementStaleItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.issues.addLabels({
@ -818,7 +819,8 @@ export class IssuesProcessor {
if (closeMessage) { if (closeMessage) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsComment(issue); this.statistics?.incrementAddedItemsComment(issue);
this.addedCloseCommentIssues.push(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.createComment({ await this.client.issues.createComment({
@ -836,7 +838,7 @@ export class IssuesProcessor {
if (closeLabel) { if (closeLabel) {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsLabel(issue); this.statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.issues.addLabels({
@ -853,7 +855,7 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementClosedItemsCount(issue); this.statistics?.incrementClosedItemsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.update({ await this.client.issues.update({
@ -872,7 +874,11 @@ export class IssuesProcessor {
private async _deleteBranch(issue: Issue): Promise<void> { private async _deleteBranch(issue: Issue): Promise<void> {
const issueLogger: IssueLogger = new IssueLogger(issue); const issueLogger: IssueLogger = new IssueLogger(issue);
issueLogger.info(`Delete branch from closed $$type - ${issue.title}`); issueLogger.info(`Delete
branch from closed $
$type
-
${issue.title}`);
const pullRequest: IPullRequest | undefined | void = const pullRequest: IPullRequest | undefined | void =
await this.getPullRequest(issue); await this.getPullRequest(issue);
@ -891,7 +897,7 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementDeletedBranchesCount(); this.statistics?.incrementDeletedBranchesCount();
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.git.deleteRef({ await this.client.git.deleteRef({
@ -926,7 +932,7 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementDeletedItemsLabelsCount(issue); this.statistics?.incrementDeletedItemsLabelsCount(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.removeLabel({ await this.client.issues.removeLabel({
@ -1060,7 +1066,7 @@ export class IssuesProcessor {
try { try {
this.operations.consumeOperation(); this.operations.consumeOperation();
this._statistics?.incrementAddedItemsLabel(issue); this.statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) { if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
@ -1087,7 +1093,7 @@ export class IssuesProcessor {
); );
await this._removeLabel(issue, staleLabel); await this._removeLabel(issue, staleLabel);
this._statistics?.incrementUndoStaleItemsCount(issue); this.statistics?.incrementUndoStaleItemsCount(issue);
} }
private async _removeCloseLabel( private async _removeCloseLabel(
@ -1124,7 +1130,7 @@ export class IssuesProcessor {
); );
await this._removeLabel(issue, closeLabel, true); await this._removeLabel(issue, closeLabel, true);
this._statistics?.incrementDeletedCloseItemsLabelsCount(issue); this.statistics?.incrementDeletedCloseItemsLabelsCount(issue);
} else { } else {
issueLogger.info( issueLogger.info(
LoggerService.white('└──'), LoggerService.white('└──'),

View File

@ -9,28 +9,28 @@ interface IGroupValue {
export class Statistics { export class Statistics {
private readonly _logger: Logger = new Logger(); private readonly _logger: Logger = new Logger();
private _processedIssuesCount = 0; processedIssuesCount = 0;
private _processedPullRequestsCount = 0; processedPullRequestsCount = 0;
private _staleIssuesCount = 0; staleIssuesCount = 0;
private _stalePullRequestsCount = 0; stalePullRequestsCount = 0;
private _undoStaleIssuesCount = 0; undoStaleIssuesCount = 0;
private _undoStalePullRequestsCount = 0; undoStalePullRequestsCount = 0;
private _operationsCount = 0; operationsCount = 0;
private _closedIssuesCount = 0; closedIssuesCount = 0;
private _closedPullRequestsCount = 0; closedPullRequestsCount = 0;
private _deletedIssuesLabelsCount = 0; deletedIssuesLabelsCount = 0;
private _deletedPullRequestsLabelsCount = 0; deletedPullRequestsLabelsCount = 0;
private _deletedCloseIssuesLabelsCount = 0; deletedCloseIssuesLabelsCount = 0;
private _deletedClosePullRequestsLabelsCount = 0; deletedClosePullRequestsLabelsCount = 0;
private _deletedBranchesCount = 0; deletedBranchesCount = 0;
private _addedIssuesLabelsCount = 0; addedIssuesLabelsCount = 0;
private _addedPullRequestsLabelsCount = 0; addedPullRequestsLabelsCount = 0;
private _addedIssuesCommentsCount = 0; addedIssuesCommentsCount = 0;
private _addedPullRequestsCommentsCount = 0; addedPullRequestsCommentsCount = 0;
private _fetchedItemsCount = 0; fetchedItemsCount = 0;
private _fetchedItemsEventsCount = 0; fetchedItemsEventsCount = 0;
private _fetchedItemsCommentsCount = 0; fetchedItemsCommentsCount = 0;
private _fetchedPullRequestsCount = 0; fetchedPullRequestsCount = 0;
incrementProcessedItemsCount( incrementProcessedItemsCount(
issue: Readonly<Issue>, issue: Readonly<Issue>,
@ -66,7 +66,7 @@ export class Statistics {
} }
setOperationsCount(operationsCount: Readonly<number>): Statistics { setOperationsCount(operationsCount: Readonly<number>): Statistics {
this._operationsCount = operationsCount; this.operationsCount = operationsCount;
return this; return this;
} }
@ -105,7 +105,7 @@ export class Statistics {
} }
incrementDeletedBranchesCount(increment: Readonly<number> = 1): Statistics { incrementDeletedBranchesCount(increment: Readonly<number> = 1): Statistics {
this._deletedBranchesCount += increment; this.deletedBranchesCount += increment;
return this; return this;
} }
@ -133,7 +133,7 @@ export class Statistics {
} }
incrementFetchedItemsCount(increment: Readonly<number> = 1): Statistics { incrementFetchedItemsCount(increment: Readonly<number> = 1): Statistics {
this._fetchedItemsCount += increment; this.fetchedItemsCount += increment;
return this; return this;
} }
@ -141,7 +141,7 @@ export class Statistics {
incrementFetchedItemsEventsCount( incrementFetchedItemsEventsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._fetchedItemsEventsCount += increment; this.fetchedItemsEventsCount += increment;
return this; return this;
} }
@ -149,7 +149,7 @@ export class Statistics {
incrementFetchedItemsCommentsCount( incrementFetchedItemsCommentsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._fetchedItemsCommentsCount += increment; this.fetchedItemsCommentsCount += increment;
return this; return this;
} }
@ -157,7 +157,7 @@ export class Statistics {
incrementFetchedPullRequestsCount( incrementFetchedPullRequestsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._fetchedPullRequestsCount += increment; this.fetchedPullRequestsCount += increment;
return this; return this;
} }
@ -185,7 +185,7 @@ export class Statistics {
private _incrementProcessedIssuesCount( private _incrementProcessedIssuesCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._processedIssuesCount += increment; this.processedIssuesCount += increment;
return this; return this;
} }
@ -193,7 +193,7 @@ export class Statistics {
private _incrementProcessedPullRequestsCount( private _incrementProcessedPullRequestsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._processedPullRequestsCount += increment; this.processedPullRequestsCount += increment;
return this; return this;
} }
@ -201,7 +201,7 @@ export class Statistics {
private _incrementStaleIssuesCount( private _incrementStaleIssuesCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._staleIssuesCount += increment; this.staleIssuesCount += increment;
return this; return this;
} }
@ -209,7 +209,7 @@ export class Statistics {
private _incrementStalePullRequestsCount( private _incrementStalePullRequestsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._stalePullRequestsCount += increment; this.stalePullRequestsCount += increment;
return this; return this;
} }
@ -217,7 +217,7 @@ export class Statistics {
private _incrementUndoStaleIssuesCount( private _incrementUndoStaleIssuesCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._undoStaleIssuesCount += increment; this.undoStaleIssuesCount += increment;
return this; return this;
} }
@ -225,7 +225,7 @@ export class Statistics {
private _incrementUndoStalePullRequestsCount( private _incrementUndoStalePullRequestsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._undoStalePullRequestsCount += increment; this.undoStalePullRequestsCount += increment;
return this; return this;
} }
@ -233,7 +233,7 @@ export class Statistics {
private _incrementClosedIssuesCount( private _incrementClosedIssuesCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._closedIssuesCount += increment; this.closedIssuesCount += increment;
return this; return this;
} }
@ -241,7 +241,7 @@ export class Statistics {
private _incrementClosedPullRequestsCount( private _incrementClosedPullRequestsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._closedPullRequestsCount += increment; this.closedPullRequestsCount += increment;
return this; return this;
} }
@ -249,7 +249,7 @@ export class Statistics {
private _incrementDeletedIssuesLabelsCount( private _incrementDeletedIssuesLabelsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._deletedIssuesLabelsCount += increment; this.deletedIssuesLabelsCount += increment;
return this; return this;
} }
@ -257,7 +257,7 @@ export class Statistics {
private _incrementDeletedPullRequestsLabelsCount( private _incrementDeletedPullRequestsLabelsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._deletedPullRequestsLabelsCount += increment; this.deletedPullRequestsLabelsCount += increment;
return this; return this;
} }
@ -265,7 +265,7 @@ export class Statistics {
private _incrementDeletedCloseIssuesLabelsCount( private _incrementDeletedCloseIssuesLabelsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._deletedCloseIssuesLabelsCount += increment; this.deletedCloseIssuesLabelsCount += increment;
return this; return this;
} }
@ -273,7 +273,7 @@ export class Statistics {
private _incrementDeletedClosePullRequestsLabelsCount( private _incrementDeletedClosePullRequestsLabelsCount(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._deletedClosePullRequestsLabelsCount += increment; this.deletedClosePullRequestsLabelsCount += increment;
return this; return this;
} }
@ -281,7 +281,7 @@ export class Statistics {
private _incrementAddedIssuesLabel( private _incrementAddedIssuesLabel(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._addedIssuesLabelsCount += increment; this.addedIssuesLabelsCount += increment;
return this; return this;
} }
@ -289,7 +289,7 @@ export class Statistics {
private _incrementAddedPullRequestsLabel( private _incrementAddedPullRequestsLabel(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._addedPullRequestsLabelsCount += increment; this.addedPullRequestsLabelsCount += increment;
return this; return this;
} }
@ -297,7 +297,7 @@ export class Statistics {
private _incrementAddedIssuesComment( private _incrementAddedIssuesComment(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._addedIssuesCommentsCount += increment; this.addedIssuesCommentsCount += increment;
return this; return this;
} }
@ -305,7 +305,7 @@ export class Statistics {
private _incrementAddedPullRequestsComment( private _incrementAddedPullRequestsComment(
increment: Readonly<number> = 1 increment: Readonly<number> = 1
): Statistics { ): Statistics {
this._addedPullRequestsCommentsCount += increment; this.addedPullRequestsCommentsCount += increment;
return this; return this;
} }
@ -314,11 +314,11 @@ export class Statistics {
this._logGroup('Processed items', [ this._logGroup('Processed items', [
{ {
name: 'Processed issues', name: 'Processed issues',
count: this._processedIssuesCount count: this.processedIssuesCount
}, },
{ {
name: 'Processed PRs', name: 'Processed PRs',
count: this._processedPullRequestsCount count: this.processedPullRequestsCount
} }
]); ]);
} }
@ -327,11 +327,11 @@ export class Statistics {
this._logGroup('New stale items', [ this._logGroup('New stale items', [
{ {
name: 'New stale issues', name: 'New stale issues',
count: this._staleIssuesCount count: this.staleIssuesCount
}, },
{ {
name: 'New stale PRs', name: 'New stale PRs',
count: this._stalePullRequestsCount count: this.stalePullRequestsCount
} }
]); ]);
} }
@ -340,11 +340,11 @@ export class Statistics {
this._logGroup('No longer stale items', [ this._logGroup('No longer stale items', [
{ {
name: 'No longer stale issues', name: 'No longer stale issues',
count: this._undoStaleIssuesCount count: this.undoStaleIssuesCount
}, },
{ {
name: 'No longer stale PRs', name: 'No longer stale PRs',
count: this._undoStalePullRequestsCount count: this.undoStalePullRequestsCount
} }
]); ]);
} }
@ -353,11 +353,11 @@ export class Statistics {
this._logGroup('Closed items', [ this._logGroup('Closed items', [
{ {
name: 'Closed issues', name: 'Closed issues',
count: this._closedIssuesCount count: this.closedIssuesCount
}, },
{ {
name: 'Closed PRs', name: 'Closed PRs',
count: this._closedPullRequestsCount count: this.closedPullRequestsCount
} }
]); ]);
} }
@ -366,11 +366,11 @@ export class Statistics {
this._logGroup('Deleted items labels', [ this._logGroup('Deleted items labels', [
{ {
name: 'Deleted issues labels', name: 'Deleted issues labels',
count: this._deletedIssuesLabelsCount count: this.deletedIssuesLabelsCount
}, },
{ {
name: 'Deleted PRs labels', name: 'Deleted PRs labels',
count: this._deletedPullRequestsLabelsCount count: this.deletedPullRequestsLabelsCount
} }
]); ]);
} }
@ -379,28 +379,28 @@ export class Statistics {
this._logGroup('Deleted close items labels', [ this._logGroup('Deleted close items labels', [
{ {
name: 'Deleted close issues labels', name: 'Deleted close issues labels',
count: this._deletedCloseIssuesLabelsCount count: this.deletedCloseIssuesLabelsCount
}, },
{ {
name: 'Deleted close PRs labels', name: 'Deleted close PRs labels',
count: this._deletedClosePullRequestsLabelsCount count: this.deletedClosePullRequestsLabelsCount
} }
]); ]);
} }
private _logDeletedBranchesCount(): void { private _logDeletedBranchesCount(): void {
this._logCount('Deleted branches', this._deletedBranchesCount); this._logCount('Deleted branches', this.deletedBranchesCount);
} }
private _logAddedIssuesAndPullRequestsLabelsCount(): void { private _logAddedIssuesAndPullRequestsLabelsCount(): void {
this._logGroup('Added items labels', [ this._logGroup('Added items labels', [
{ {
name: 'Added issues labels', name: 'Added issues labels',
count: this._addedIssuesLabelsCount count: this.addedIssuesLabelsCount
}, },
{ {
name: 'Added PRs labels', name: 'Added PRs labels',
count: this._addedPullRequestsLabelsCount count: this.addedPullRequestsLabelsCount
} }
]); ]);
} }
@ -409,33 +409,33 @@ export class Statistics {
this._logGroup('Added items comments', [ this._logGroup('Added items comments', [
{ {
name: 'Added issues comments', name: 'Added issues comments',
count: this._addedIssuesCommentsCount count: this.addedIssuesCommentsCount
}, },
{ {
name: 'Added PRs comments', name: 'Added PRs comments',
count: this._addedPullRequestsCommentsCount count: this.addedPullRequestsCommentsCount
} }
]); ]);
} }
private _logFetchedItemsCount(): void { private _logFetchedItemsCount(): void {
this._logCount('Fetched items', this._fetchedItemsCount); this._logCount('Fetched items', this.fetchedItemsCount);
} }
private _logFetchedItemsEventsCount(): void { private _logFetchedItemsEventsCount(): void {
this._logCount('Fetched items events', this._fetchedItemsEventsCount); this._logCount('Fetched items events', this.fetchedItemsEventsCount);
} }
private _logFetchedItemsCommentsCount(): void { private _logFetchedItemsCommentsCount(): void {
this._logCount('Fetched items comments', this._fetchedItemsCommentsCount); this._logCount('Fetched items comments', this.fetchedItemsCommentsCount);
} }
private _logFetchedPullRequestsCount(): void { private _logFetchedPullRequestsCount(): void {
this._logCount('Fetched pull requests', this._fetchedPullRequestsCount); this._logCount('Fetched pull requests', this.fetchedPullRequestsCount);
} }
private _logOperationsCount(): void { private _logOperationsCount(): void {
this._logCount('Operations performed', this._operationsCount); this._logCount('Operations performed', this.operationsCount);
} }
private _logCount(name: Readonly<string>, count: Readonly<number>): void { private _logCount(name: Readonly<string>, count: Readonly<number>): void {