mirror of
https://github.com/actions/stale.git
synced 2025-12-10 03:57:04 +00:00
feat(statistics): display some stats in the logs (#337)
* test: add more coverage * docs: reorder and enhance typo * docs(contributing): add more information about the npm scripts * feat(statistics): add simple statistics * feat(statistics): add more stats * refactor(issues-processor): remove some options from the constructor it should have been only useful for the tests * feat(statistics): add stats for new stale or undo stale issues * chore(rebase): handle rebase conflicts
This commit is contained in:
committed by
GitHub
parent
63ae8ac024
commit
419a53bc05
@@ -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';
|
||||
|
||||
@@ -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 : []),
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
@@ -46,7 +46,7 @@ describe('assignees options', (): void => {
|
||||
};
|
||||
|
||||
const setProcessor = () => {
|
||||
processor = new IssuesProcessor(
|
||||
processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? testIssueList : []),
|
||||
|
||||
38
__tests__/classes/issues-processor-mock.ts
Normal file
38
__tests__/classes/issues-processor-mock.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,5 +41,6 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||
exemptPrAssignees: '',
|
||||
exemptAllAssignees: false,
|
||||
exemptAllIssueAssignees: undefined,
|
||||
exemptAllPrAssignees: undefined
|
||||
exemptAllPrAssignees: undefined,
|
||||
enableStatistics: false
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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';
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ITestData {
|
||||
describe('milestones options', (): void => {
|
||||
let opts: IIssuesProcessorOptions;
|
||||
let testIssueList: Issue[];
|
||||
let processor: IssuesProcessor;
|
||||
let processor: IssuesProcessorMock;
|
||||
|
||||
const setTestIssueList = (
|
||||
isPullRequest: boolean,
|
||||
@@ -37,7 +37,7 @@ describe('milestones options', (): void => {
|
||||
};
|
||||
|
||||
const setProcessor = () => {
|
||||
processor = new IssuesProcessor(
|
||||
processor = new IssuesProcessorMock(
|
||||
opts,
|
||||
async () => 'abot',
|
||||
async p => (p === 1 ? testIssueList : []),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {Issue} from '../src/classes/issue';
|
||||
import {IssuesProcessor} from '../src/classes/issues-processor';
|
||||
import {IIssue} from '../src/interfaces/issue';
|
||||
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';
|
||||
|
||||
let issuesProcessorBuilder: IssuesProcessorBuilder;
|
||||
let issuesProcessor: IssuesProcessor;
|
||||
let issuesProcessor: IssuesProcessorMock;
|
||||
|
||||
describe('only-labels option', (): void => {
|
||||
beforeEach((): void => {
|
||||
@@ -1140,8 +1140,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 : []),
|
||||
|
||||
Reference in New Issue
Block a user