tools: add details about comments in show-pr
Add individual counts of different types of comments and
reviews. Sorting the old from the new requires adding a --days-back
command line option to match the one used in the report command.
@@ -16,6 +16,8 @@ import (
)
func newShowPRCommand() *cobra.Command {
+ var daysBack int
+
cmd := &cobra.Command{
Use: "show-pr",
Short: "Dump details for a pull request",
@@ -48,6 +50,8 @@ func newShowPRCommand() *cobra.Command {
return errors.Wrap(err, fmt.Sprintf("failed to fetch pull request %d", prID))
}
+ earliestDate := time.Now().AddDate(0, 0, daysBack*-1)
+
query := &util.PullRequestQuery{
Org: orgName,
Repo: repoName,
@@ -71,6 +75,7 @@ func newShowPRCommand() *cobra.Command {
}
theStats := &stats.Stats{
Query: query,
+ EarliestDate: earliestDate,
Buckets: reportBuckets,
}
if err := theStats.ProcessOne(pr); err != nil {
@@ -103,10 +108,14 @@ func newShowPRCommand() *cobra.Command {
fmt.Printf("LGTM: %v\n", prd.LGTM)
fmt.Printf("Prioritized: %v\n", prd.Prioritized)
fmt.Printf("Stale: %v\n", prd.Stale)
+ fmt.Printf("Reviews: %3d / %3d\n", prd.RecentReviewCount, len(prd.Reviews))
+ fmt.Printf("PR Comments: %3d / %3d\n", prd.RecentPRCommentCount, len(prd.PullRequestComments))
+ fmt.Printf("Issue comments: %3d / %3d\n", prd.RecentIssueCommentCount, len(prd.IssueComments))
return nil
},
}
+ cmd.Flags().IntVar(&daysBack, "days-back", 7, "how many days back to query")
return cmd
}
