Skip to content

Commit

Permalink
feat(statistics): use the word "items" when something concern both is…
Browse files Browse the repository at this point in the history
…sues and prs
  • Loading branch information
C0ZEN committed Mar 9, 2021
1 parent 56d2542 commit 929bcd9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
51 changes: 25 additions & 26 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class IssuesProcessor {
// find any comments since date on the given issue
try {
this._operations.consumeOperation();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedIssuesCommentsCount();
(_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,
Expand Down Expand Up @@ -463,7 +463,7 @@ class IssuesProcessor {
direction: this.options.ascending ? 'asc' : 'desc',
page
});
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedIssuesCount(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));
}
catch (error) {
Expand All @@ -480,7 +480,7 @@ class IssuesProcessor {
const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Checking for label on $$type`);
this._operations.consumeOperation();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedIssuesEventsCount();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount();
const options = this.client.issues.listEvents.endpoint.merge({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
Expand Down Expand Up @@ -1125,9 +1125,9 @@ class Statistics {
this._deletedBranchesCount = 0;
this._addedLabelsCount = 0;
this._addedCommentsCount = 0;
this._fetchedIssuesCount = 0;
this._fetchedIssuesEventsCount = 0;
this._fetchedIssuesCommentsCount = 0;
this._fetchedItemsCount = 0;
this._fetchedItemsEventsCount = 0;
this._fetchedItemsCommentsCount = 0;
this._fetchedPullRequestsCount = 0;
}
incrementProcessedItemsCount(issue, increment = 1) {
Expand Down Expand Up @@ -1178,16 +1178,16 @@ class Statistics {
this._addedCommentsCount += increment;
return this;
}
incrementFetchedIssuesCount(increment = 1) {
this._fetchedIssuesCount += increment;
incrementFetchedItemsCount(increment = 1) {
this._fetchedItemsCount += increment;
return this;
}
incrementFetchedIssuesEventsCount(increment = 1) {
this._fetchedIssuesEventsCount += increment;
incrementFetchedItemsEventsCount(increment = 1) {
this._fetchedItemsEventsCount += increment;
return this;
}
incrementFetchedIssuesCommentsCount(increment = 1) {
this._fetchedIssuesCommentsCount += increment;
incrementFetchedItemsCommentsCount(increment = 1) {
this._fetchedItemsCommentsCount += increment;
return this;
}
incrementFetchedPullRequestsCount(increment = 1) {
Expand All @@ -1205,12 +1205,11 @@ class Statistics {
this._logDeletedBranchesCount();
this._logAddedLabelsCount();
this._logAddedCommentsCount();
this._logFetchedIssuesCount();
this._logFetchedIssuesEventsCount();
this._logFetchedIssuesCommentsCount();
this._logFetchedItemsCount();
this._logFetchedItemsEventsCount();
this._logFetchedItemsCommentsCount();
this._logFetchedPullRequestsCount();
this._logOperationsCount();
this._logger.info('---');
return this;
}
_incrementProcessedIssuesCount(increment = 1) {
Expand Down Expand Up @@ -1308,14 +1307,14 @@ class Statistics {
_logAddedCommentsCount() {
this._logCount('Added comments', this._addedCommentsCount);
}
_logFetchedIssuesCount() {
this._logCount('Fetched issues', this._fetchedIssuesCount);
_logFetchedItemsCount() {
this._logCount('Fetched items', this._fetchedItemsCount);
}
_logFetchedIssuesEventsCount() {
this._logCount('Fetched issues events', this._fetchedIssuesEventsCount);
_logFetchedItemsEventsCount() {
this._logCount('Fetched items events', this._fetchedItemsEventsCount);
}
_logFetchedIssuesCommentsCount() {
this._logCount('Fetched issues comments', this._fetchedIssuesCommentsCount);
_logFetchedItemsCommentsCount() {
this._logCount('Fetched items comments', this._fetchedItemsCommentsCount);
}
_logFetchedPullRequestsCount() {
this._logCount('Fetched pull requests', this._fetchedPullRequestsCount);
Expand Down Expand Up @@ -1370,7 +1369,7 @@ class Statistics {
const longestValue = this._getLongestGroupValue(onlyValuesSet);
for (const [index, value] of onlyValuesSet.entries()) {
const prefix = index === onlyValuesSet.length - 1 ? '└──' : '├──';
this._logCount(`${prefix} ${value.name.padEnd(longestValue, ' ')}`, value.count);
this._logCount(`${chalk_1.default.white(prefix)} ${value.name.padEnd(longestValue, ' ')}`, value.count);
}
}
_getLongestGroupValue(values) {
Expand Down Expand Up @@ -10361,7 +10360,7 @@ module.exports = require("zlib");;
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
Expand All @@ -10375,7 +10374,7 @@ module.exports = require("zlib");;
/******/ return module;
/******/ };
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/compat */
/******/
/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
Expand All @@ -10384,4 +10383,4 @@ module.exports = require("zlib");;
/******/ // Load entry module and return exports
/******/ return __nccwpck_require__(3109);
/******/ })()
;
;
6 changes: 3 additions & 3 deletions src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class IssuesProcessor {
// find any comments since date on the given issue
try {
this._operations.consumeOperation();
this._statistics?.incrementFetchedIssuesCommentsCount();
this._statistics?.incrementFetchedItemsCommentsCount();
const comments = await this.client.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down Expand Up @@ -366,7 +366,7 @@ export class IssuesProcessor {
page
}
);
this._statistics?.incrementFetchedIssuesCount(issueResult.data.length);
this._statistics?.incrementFetchedItemsCount(issueResult.data.length);

return issueResult.data.map(
(issue: Readonly<IIssue>): Issue => new Issue(this.options, issue)
Expand All @@ -388,7 +388,7 @@ export class IssuesProcessor {
issueLogger.info(`Checking for label on $$type`);

this._operations.consumeOperation();
this._statistics?.incrementFetchedIssuesEventsCount();
this._statistics?.incrementFetchedItemsEventsCount();
const options = this.client.issues.listEvents.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
38 changes: 19 additions & 19 deletions src/classes/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class Statistics {
private _deletedBranchesCount = 0;
private _addedLabelsCount = 0;
private _addedCommentsCount = 0;
private _fetchedIssuesCount = 0;
private _fetchedIssuesEventsCount = 0;
private _fetchedIssuesCommentsCount = 0;
private _fetchedItemsCount = 0;
private _fetchedItemsEventsCount = 0;
private _fetchedItemsCommentsCount = 0;
private _fetchedPullRequestsCount = 0;

incrementProcessedItemsCount(
Expand Down Expand Up @@ -110,24 +110,24 @@ export class Statistics {
return this;
}

incrementFetchedIssuesCount(increment: Readonly<number> = 1): Statistics {
this._fetchedIssuesCount += increment;
incrementFetchedItemsCount(increment: Readonly<number> = 1): Statistics {
this._fetchedItemsCount += increment;

return this;
}

incrementFetchedIssuesEventsCount(
incrementFetchedItemsEventsCount(
increment: Readonly<number> = 1
): Statistics {
this._fetchedIssuesEventsCount += increment;
this._fetchedItemsEventsCount += increment;

return this;
}

incrementFetchedIssuesCommentsCount(
incrementFetchedItemsCommentsCount(
increment: Readonly<number> = 1
): Statistics {
this._fetchedIssuesCommentsCount += increment;
this._fetchedItemsCommentsCount += increment;

return this;
}
Expand All @@ -151,9 +151,9 @@ export class Statistics {
this._logDeletedBranchesCount();
this._logAddedLabelsCount();
this._logAddedCommentsCount();
this._logFetchedIssuesCount();
this._logFetchedIssuesEventsCount();
this._logFetchedIssuesCommentsCount();
this._logFetchedItemsCount();
this._logFetchedItemsEventsCount();
this._logFetchedItemsCommentsCount();
this._logFetchedPullRequestsCount();
this._logOperationsCount();

Expand Down Expand Up @@ -296,16 +296,16 @@ export class Statistics {
this._logCount('Added comments', this._addedCommentsCount);
}

private _logFetchedIssuesCount(): void {
this._logCount('Fetched issues', this._fetchedIssuesCount);
private _logFetchedItemsCount(): void {
this._logCount('Fetched items', this._fetchedItemsCount);
}

private _logFetchedIssuesEventsCount(): void {
this._logCount('Fetched issues events', this._fetchedIssuesEventsCount);
private _logFetchedItemsEventsCount(): void {
this._logCount('Fetched items events', this._fetchedItemsEventsCount);
}

private _logFetchedIssuesCommentsCount(): void {
this._logCount('Fetched issues comments', this._fetchedIssuesCommentsCount);
private _logFetchedItemsCommentsCount(): void {
this._logCount('Fetched items comments', this._fetchedItemsCommentsCount);
}

private _logFetchedPullRequestsCount(): void {
Expand Down Expand Up @@ -376,7 +376,7 @@ export class Statistics {
const prefix = index === onlyValuesSet.length - 1 ? '└──' : '├──';

this._logCount(
`${prefix} ${value.name.padEnd(longestValue, ' ')}`,
`${chalk.white(prefix)} ${value.name.padEnd(longestValue, ' ')}`,
value.count
);
}
Expand Down

0 comments on commit 929bcd9

Please sign in to comment.