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;
assignees: IssueMember[];
labels?: IssueLabel[];
commentsCount?: number;
thumbsUpCount?: number;
}
export interface SearchedIssue {
@ -153,6 +155,8 @@ export function serializeIssue(value: IssueShape): IssueShape {
color: label.color,
name: label.name,
})),
commentsCount: value.commentsCount,
thumbsUpCount: value.thumbsUpCount,
};
return serialized;
}
@ -172,5 +176,7 @@ export class Issue implements IssueShape {
public readonly assignees: IssueMember[],
public readonly closedDate?: Date,
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;
}
export interface PullRequestMember {
name: string;
avatarUrl: string;
url: string;
}
export interface PullRequestReviewer {
isCodeOwner: boolean;
reviewer: PullRequestMember;
}
export interface PullRequestShape extends IssueOrPullRequest {
readonly author: {
readonly name: string;
readonly avatarUrl: string;
readonly url: string;
};
readonly author: PullRequestMember;
readonly state: PullRequestState;
readonly mergedDate?: Date;
readonly refs?: PullRequestRefs;
readonly isDraft?: boolean;
readonly additions?: number;
readonly deletions?: number;
readonly reviewRequests?: { isCodeOwner: boolean; reviewer: PullRequestMember }[];
readonly assignees?: PullRequestMember[];
}
export interface SearchedPullRequest {
@ -87,6 +98,10 @@ export function serializePullRequest(value: PullRequest): PullRequestShape {
}
: undefined,
isDraft: value.isDraft,
additions: value.additions,
deletions: value.deletions,
reviewRequests: value.reviewRequests,
assignees: value.assignees,
};
return serialized;
}
@ -146,6 +161,10 @@ export class PullRequest implements PullRequestShape {
public readonly mergedDate?: Date,
public readonly refs?: PullRequestRefs,
public readonly isDraft?: boolean,
public readonly additions?: number,
public readonly deletions?: number,
public readonly reviewRequests?: PullRequestReviewer[],
public readonly assignees?: PullRequestMember[],
) {}
get closed(): boolean {

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

@ -2504,6 +2504,8 @@ permalink
number
title
state
additions
deletions
updatedAt
closedAt
mergedAt
@ -2533,6 +2535,26 @@ headRepository {
login
}
}
reviewRequests {
nodes {
asCodeOwner
id
requestedReviewer {
... on User {
login
avatarUrl
url
}
}
}
}
assignees(first: 10) {
nodes {
login
avatarUrl
url
}
}
`;
const issueNodeProperties = `
@ -2567,5 +2589,11 @@ const issueNodeProperties = `
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[] };
labels?: { nodes: IssueLabel[] };
reactions?: {
totalCount: number;
};
comments?: {
totalCount: number;
};
}
export type GitHubPullRequestReviewDecision = 'CHANGES_REQUESTED' | 'APPROVED' | 'REVIEW_REQUIRED';
@ -128,6 +134,25 @@ export interface GitHubDetailedPullRequest extends GitHubPullRequest {
checksUrl: string;
totalCommentsCount: number;
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 {
@ -194,6 +219,21 @@ export namespace GitHubPullRequest {
isCrossRepository: pr.isCrossRepository,
},
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,
name: label.name,
})),
value.comments?.totalCount,
value.reactions?.totalCount,
);
}
}

Loading…
Cancel
Save