mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-21 19:25:46 +08:00
feat: add doCheckInactive
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Octokit } from '@octokit/rest';
|
||||
|
||||
import { TEmoji, TLockReasons, TUpdateMode, TIssueState } from '../types';
|
||||
import { IIssueBaseInfo, IIssueCoreEngine } from './types';
|
||||
import { IIssueBaseInfo, IIssueCoreEngine, IListIssuesParams, TListIssuesResults } from './types';
|
||||
|
||||
export class IssueCoreEngine implements IIssueCoreEngine {
|
||||
private owner!: string;
|
||||
@@ -124,6 +124,22 @@ export class IssueCoreEngine implements IIssueCoreEngine {
|
||||
});
|
||||
}
|
||||
|
||||
public async listIssues(params: IListIssuesParams, page = 1) {
|
||||
const { octokit, owner, repo } = this;
|
||||
const { data } = await octokit.issues.listForRepo({
|
||||
...params,
|
||||
owner,
|
||||
repo,
|
||||
per_page: 100,
|
||||
page,
|
||||
});
|
||||
let issues = [...data] as unknown as TListIssuesResults;
|
||||
if (issues.length >= 100) {
|
||||
issues = issues.concat(await this.listIssues(params, page + 1));
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
public async lockIssue(lockReason: TLockReasons) {
|
||||
const { owner, repo, octokit, issueNumber } = this;
|
||||
const params: any = {
|
||||
@@ -165,7 +181,7 @@ export class IssueCoreEngine implements IIssueCoreEngine {
|
||||
issue_number: issueNumber,
|
||||
});
|
||||
|
||||
const baseLabels = issue.data.labels.map(({ name }: any) => name);
|
||||
const baseLabels: string[] = issue.data.labels.map(({ name }: any) => name);
|
||||
const removeLabels = baseLabels.filter(name => labels.includes(name));
|
||||
|
||||
for (const label of removeLabels) {
|
||||
@@ -190,7 +206,7 @@ export class IssueCoreEngine implements IIssueCoreEngine {
|
||||
issue_number: issueNumber,
|
||||
});
|
||||
|
||||
const baseLabels = issue.data.labels.map(({ name }: any) => name);
|
||||
const baseLabels: string[] = issue.data.labels.map(({ name }: any) => name);
|
||||
const removeLabels = baseLabels.filter(name => !labels.includes(name));
|
||||
const addLabels = labels.filter(name => !baseLabels.includes(name));
|
||||
|
||||
@@ -257,12 +273,4 @@ export class IssueCoreEngine implements IIssueCoreEngine {
|
||||
assignees: assignees?.length ? assignees : baseAssignessName,
|
||||
});
|
||||
}
|
||||
|
||||
public async queryIssues() {
|
||||
|
||||
}
|
||||
|
||||
private async listIssues(params, page = 1) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -8,13 +8,26 @@ export interface IIssueBaseInfo {
|
||||
}
|
||||
|
||||
export interface IListIssuesParams {
|
||||
owner: string;
|
||||
repo: string;
|
||||
state: 'all' | 'open' | 'closed';
|
||||
|
||||
|
||||
state: TIssueState | 'all';
|
||||
creator?: string;
|
||||
assignee?: string;
|
||||
mentioned?: string;
|
||||
labels?: string;
|
||||
}
|
||||
|
||||
export type TListIssuesResult = {
|
||||
number: number;
|
||||
title: string;
|
||||
body: string;
|
||||
labels: {
|
||||
name: string;
|
||||
}[];
|
||||
updated_at: string;
|
||||
pull_request?: any;
|
||||
}
|
||||
|
||||
export type TListIssuesResults = TListIssuesResult[];
|
||||
|
||||
export interface IIssueCoreEngine {
|
||||
setIssueNumber(newIssueNumber: number): void;
|
||||
addAssignees(assignees: string[]): Promise<void>;
|
||||
@@ -40,6 +53,7 @@ export interface IIssueCoreEngine {
|
||||
|
||||
deleteComment(commentId: number): Promise<void>;
|
||||
|
||||
listIssues(params: IListIssuesParams): Promise<TListIssuesResults>;
|
||||
lockIssue(lockReason: TLockReasons): Promise<void>;
|
||||
|
||||
openIssue(): Promise<void>;
|
||||
|
Reference in New Issue
Block a user