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

feat(statistics): display some stats in the logs #337

Merged
merged 19 commits into from
Mar 1, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 63 additions & 53 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions __tests__/any-of-labels.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Issue} from '../src/classes/issue';
import {IssuesProcessor} from '../src/classes/issues-processor';
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
import {IssuesProcessorMock} from './classes/issues-processor-mock';
import {DefaultProcessorOptions} from './constants/default-processor-options';
import {generateIssue} from './functions/generate-issue';

Expand Down Expand Up @@ -95,8 +95,8 @@ class IssuesProcessorBuilder {
return this;
}

build(): IssuesProcessor {
return new IssuesProcessor(
build(): IssuesProcessorMock {
return new IssuesProcessorMock(
this._options,
async () => 'abot',
async p => (p === 1 ? this._issues : []),
Expand Down
6 changes: 3 additions & 3 deletions __tests__/assignees.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Issue} from '../src/classes/issue';
import {IssuesProcessor} from '../src/classes/issues-processor';
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
import {IssuesProcessorMock} from './classes/issues-processor-mock';
import {DefaultProcessorOptions} from './constants/default-processor-options';
import {generateIssue} from './functions/generate-issue';

Expand All @@ -21,7 +21,7 @@ interface ITestData {
describe('assignees options', (): void => {
let opts: IIssuesProcessorOptions;
let testIssueList: Issue[];
let processor: IssuesProcessor;
let processor: IssuesProcessorMock;

const setTestIssueList = (
isPullRequest: boolean,
Expand All @@ -46,7 +46,7 @@ describe('assignees options', (): void => {
};

const setProcessor = () => {
processor = new IssuesProcessor(
processor = new IssuesProcessorMock(
opts,
async () => 'abot',
async p => (p === 1 ? testIssueList : []),
Expand Down
38 changes: 38 additions & 0 deletions __tests__/classes/issues-processor-mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {Issue} from '../../src/classes/issue';
import {IssuesProcessor} from '../../src/classes/issues-processor';
import {IComment} from '../../src/interfaces/comment';
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';

export class IssuesProcessorMock extends IssuesProcessor {
constructor(
options: IIssuesProcessorOptions,
getActor?: () => Promise<string>,
getIssues?: (page: number) => Promise<Issue[]>,
listIssueComments?: (
issueNumber: number,
sinceDate: string
) => Promise<IComment[]>,
getLabelCreationDate?: (
issue: Issue,
label: string
) => Promise<string | undefined>
) {
super(options);

if (getActor) {
this.getActor = getActor;
}

if (getIssues) {
this.getIssues = getIssues;
}

if (listIssueComments) {
this.listIssueComments = listIssueComments;
}

if (getLabelCreationDate) {
this.getLabelCreationDate = getLabelCreationDate;
}
}
}
3 changes: 2 additions & 1 deletion __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
exemptPrAssignees: '',
exemptAllAssignees: false,
exemptAllIssueAssignees: undefined,
exemptAllPrAssignees: undefined
exemptAllPrAssignees: undefined,
enableStatistics: false
});
Loading