Browse Source

Adds fields to PullRequest and Issue

main
Keith Daulton 1 year ago
committed by Keith Daulton
parent
commit
f9e19a49b6
5 changed files with 101 additions and 6 deletions
  1. +1
    -1
      .vscode/queries.github-graphql-nb
  2. +6
    -0
      src/git/models/issue.ts
  3. +24
    -5
      src/git/models/pullRequest.ts
  4. +28
    -0
      src/plus/github/github.ts
  5. +42
    -0
      src/plus/github/models.ts

+ 1
- 1
.vscode/queries.github-graphql-nb
File diff suppressed because it is too large
View File


+ 6
- 0
src/git/models/issue.ts View File

@ -34,6 +34,8 @@ export interface IssueShape extends IssueOrPullRequest {
author: IssueMember; author: IssueMember;
assignees: IssueMember[]; assignees: IssueMember[];
labels?: IssueLabel[]; labels?: IssueLabel[];
commentsCount?: number;
thumbsUpCount?: number;
} }
export interface SearchedIssue { export interface SearchedIssue {
@ -153,6 +155,8 @@ export function serializeIssue(value: IssueShape): IssueShape {
color: label.color, color: label.color,
name: label.name, name: label.name,
})), })),
commentsCount: value.commentsCount,
thumbsUpCount: value.thumbsUpCount,
}; };
return serialized; return serialized;
} }
@ -172,5 +176,7 @@ export class Issue implements IssueShape {
public readonly assignees: IssueMember[], public readonly assignees: IssueMember[],
public readonly closedDate?: Date, public readonly closedDate?: Date,
public readonly labels?: IssueLabel[], public readonly labels?: IssueLabel[],
public readonly commentsCount?: number,
public readonly thumbsUpCount?: number,
) {} ) {}
} }

+ 24
- 5
src/git/models/pullRequest.ts View File

@ -28,16 +28,27 @@ export interface PullRequestRefs {
isCrossRepository: boolean; isCrossRepository: boolean;
} }
export interface PullRequestMember {
name: string;
avatarUrl: string;
url: string;
}
export interface PullRequestReviewer {
isCodeOwner: boolean;
reviewer: PullRequestMember;
}
export interface PullRequestShape extends IssueOrPullRequest { export interface PullRequestShape extends IssueOrPullRequest {
readonly author: {
readonly name: string;
readonly avatarUrl: string;
readonly url: string;
};
readonly author: PullRequestMember;
readonly state: PullRequestState; readonly state: PullRequestState;
readonly mergedDate?: Date; readonly mergedDate?: Date;
readonly refs?: PullRequestRefs; readonly refs?: PullRequestRefs;
readonly isDraft?: boolean; readonly isDraft?: boolean;
readonly additions?: number;
readonly deletions?: number;
readonly reviewRequests?: { isCodeOwner: boolean; reviewer: PullRequestMember }[];
readonly assignees?: PullRequestMember[];
} }
export interface SearchedPullRequest { export interface SearchedPullRequest {
@ -87,6 +98,10 @@ export function serializePullRequest(value: PullRequest): PullRequestShape {
} }
: undefined, : undefined,
isDraft: value.isDraft, isDraft: value.isDraft,
additions: value.additions,
deletions: value.deletions,
reviewRequests: value.reviewRequests,
assignees: value.assignees,
}; };
return serialized; return serialized;
} }
@ -146,6 +161,10 @@ export class PullRequest implements PullRequestShape {
public readonly mergedDate?: Date, public readonly mergedDate?: Date,
public readonly refs?: PullRequestRefs, public readonly refs?: PullRequestRefs,
public readonly isDraft?: boolean, public readonly isDraft?: boolean,
public readonly additions?: number,
public readonly deletions?: number,
public readonly reviewRequests?: PullRequestReviewer[],
public readonly assignees?: PullRequestMember[],
) {} ) {}
get closed(): boolean { get closed(): boolean {

+ 28
- 0
src/plus/github/github.ts View File

@ -2504,6 +2504,8 @@ permalink
number number
title title
state state
additions
deletions
updatedAt updatedAt
closedAt closedAt
mergedAt mergedAt
@ -2533,6 +2535,26 @@ headRepository {
login login
} }
} }
reviewRequests {
nodes {
asCodeOwner
id
requestedReviewer {
... on User {
login
avatarUrl
url
}
}
}
}
assignees(first: 10) {
nodes {
login
avatarUrl
url
}
}
`; `;
const issueNodeProperties = ` const issueNodeProperties = `
@ -2567,5 +2589,11 @@ const issueNodeProperties = `
name name
} }
} }
reactions(content: THUMBS_UP) {
totalCount
}
comments {
totalCount
}
} }
`; `;

+ 42
- 0
src/plus/github/models.ts View File

@ -99,6 +99,12 @@ export interface GitHubDetailedIssue extends GitHubIssueOrPullRequest {
}; };
assignees: { nodes: IssueMember[] }; assignees: { nodes: IssueMember[] };
labels?: { nodes: IssueLabel[] }; labels?: { nodes: IssueLabel[] };
reactions?: {
totalCount: number;
};
comments?: {
totalCount: number;
};
} }
export type GitHubPullRequestReviewDecision = 'CHANGES_REQUESTED' | 'APPROVED' | 'REVIEW_REQUIRED'; export type GitHubPullRequestReviewDecision = 'CHANGES_REQUESTED' | 'APPROVED' | 'REVIEW_REQUIRED';
@ -128,6 +134,25 @@ export interface GitHubDetailedPullRequest extends GitHubPullRequest {
checksUrl: string; checksUrl: string;
totalCommentsCount: number; totalCommentsCount: number;
mergeable: GitHubPullRequestMergeableState; mergeable: GitHubPullRequestMergeableState;
additions: number;
deletions: number;
reviewRequests: {
nodes: {
asCodeOwner: boolean;
requestedReviewer: {
login: string;
avatarUrl: string;
url: string;
};
}[];
};
assignees: {
nodes: {
login: string;
avatarUrl: string;
url: string;
}[];
};
} }
export namespace GitHubPullRequest { export namespace GitHubPullRequest {
@ -194,6 +219,21 @@ export namespace GitHubPullRequest {
isCrossRepository: pr.isCrossRepository, isCrossRepository: pr.isCrossRepository,
}, },
pr.isDraft, pr.isDraft,
pr.additions,
pr.deletions,
pr.reviewRequests.nodes.map(r => ({
isCodeOwner: r.asCodeOwner,
reviewer: {
name: r.requestedReviewer.login,
avatarUrl: r.requestedReviewer.avatarUrl,
url: r.requestedReviewer.url,
},
})),
pr.assignees.nodes.map(r => ({
name: r.login,
avatarUrl: r.avatarUrl,
url: r.url,
})),
); );
} }
} }
@ -230,6 +270,8 @@ export namespace GitHubDetailedIssue {
color: label.color, color: label.color,
name: label.name, name: label.name,
})), })),
value.comments?.totalCount,
value.reactions?.totalCount,
); );
} }
} }

Loading…
Cancel
Save