diff --git a/cli/cmds_prs.go b/cli/cmds_prs.go index ca65b7a..f8702e0 100644 --- a/cli/cmds_prs.go +++ b/cli/cmds_prs.go @@ -144,12 +144,14 @@ func CmdPRs(_ *cobra.Command, _ []string) error { {Name: "user", FieldID: p.FieldIDs["User"], Type: gh.ItemValueTypeText, Value: pr.Author}, {Name: "daysOpen", FieldID: p.FieldIDs["Open Days"], Type: gh.ItemValueTypeNumber, Value: daysOpen}, {Name: "daysWait", FieldID: p.FieldIDs["Waiting Days"], Type: gh.ItemValueTypeNumber, Value: daysWaiting}, - {Name: "commentCount", FieldID: p.FieldIDs["Comment Count"], Type: gh.ItemValueTypeNumber, Value: pr.TotalCommentsCount}, + {Name: "commentCount", FieldID: p.FieldIDs["Comment Count"], Type: gh.ItemValueTypeNumber, Value: pr.TotalCommentCount}, {Name: "reviewCount", FieldID: p.FieldIDs["Review Count"], Type: gh.ItemValueTypeNumber, Value: pr.TotalReviewCount}, + {Name: "reviewCommentCount", FieldID: p.FieldIDs["Review Comment Count"], Type: gh.ItemValueTypeNumber, Value: pr.ReviewCommentCount}, } if pr.FilteredReviewCount > 0 { fields = append(fields, gh.ProjectItemField{Name: "filteredReviewCount", FieldID: p.FieldIDs["Filtered Review Count"], Type: gh.ItemValueTypeNumber, Value: pr.FilteredReviewCount}) + fields = append(fields, gh.ProjectItemField{Name: "filteredReviewCommentCount", FieldID: p.FieldIDs["Filtered Review Comment Count"], Type: gh.ItemValueTypeNumber, Value: pr.FilteredReviewCommentCount}) } err = p.UpdateItem(*iid, fields) diff --git a/lib/gh/pr_gql.go b/lib/gh/pr_gql.go index 1c8d85c..c48c1c9 100644 --- a/lib/gh/pr_gql.go +++ b/lib/gh/pr_gql.go @@ -8,20 +8,22 @@ import ( ) type PullRequest struct { - NodeID string - Author string - Number int - Title string - State string - ReviewDecision string - CreatedAt time.Time - UpdatedAt time.Time - ClosedAt time.Time - Draft bool - Milestone string - TotalCommentsCount int - TotalReviewCount int - FilteredReviewCount int + NodeID string + Author string + Number int + Title string + State string + ReviewDecision string + CreatedAt time.Time + UpdatedAt time.Time + ClosedAt time.Time + Draft bool + Milestone string + TotalCommentCount int + TotalReviewCount int + ReviewCommentCount int + FilteredReviewCount int + FilteredReviewCommentCount int Assignees []string AssociatedLabels map[string]bool @@ -68,6 +70,10 @@ type pullRequestsQuery struct { Author struct { Login string } + Comments struct { + TotalCount int + } + State string } } `graphql:"reviews(first: 100)"` @@ -143,7 +149,7 @@ func (q pullRequestsQuery) flatten(reviewers map[string]struct{}) []PullRequest ClosedAt: pullRequest.ClosedAt, Draft: pullRequest.IsDraft, Milestone: pullRequest.Milestone.Title, - TotalCommentsCount: pullRequest.TotalCommentsCount, + TotalCommentCount: pullRequest.TotalCommentsCount, AssociatedLabels: make(map[string]bool), AssociatedProjectNumbers: make(map[int]bool), } @@ -161,11 +167,17 @@ func (q pullRequestsQuery) flatten(reviewers map[string]struct{}) []PullRequest } for _, review := range pullRequest.Reviews.Nodes { + // We're only interested in `APPROVED`, `CHANGES_REQUESTED`, and `DISMISSED` states. + if review.State == string(githubv4.PullRequestReviewStateCommented) || review.State == string(githubv4.PullRequestReviewStatePending) { + continue + } pr.TotalReviewCount++ + pr.ReviewCommentCount += review.Comments.TotalCount // Only add filtered review count if `reviewers` filter was provided if _, ok := reviewers[review.Author.Login]; ok { pr.FilteredReviewCount++ + pr.FilteredReviewCommentCount += review.Comments.TotalCount } }