Skip to content

Commit

Permalink
tools: redefine stale in the report as having the lifecycle/stale label
Browse files Browse the repository at this point in the history
Instead of doing the calculation ourselves and potentially having
different results, use the existing label applied by the bot.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
  • Loading branch information
dhellmann committed Feb 2, 2021
1 parent 9b80113 commit 6582232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions tools/cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func newReportCommand() *cobra.Command {
}
stale := stats.Bucket{
Rule: func(prd *stats.PullRequestDetails) bool {
return prd.Pull.UpdatedAt.Before(query.StaleDate)
return prd.Stale
},
}
otherActive := stats.Bucket{
Expand Down Expand Up @@ -212,8 +212,7 @@ func newReportCommand() *cobra.Command {

report.SortByID(stale.Requests)
report.ShowPRs(
fmt.Sprintf("Stale (older than %d months, no discussion in last %d days)",
staleMonths, daysBack),
"Other lifecycle/stale",
stale.Requests,
false,
)
Expand Down
10 changes: 8 additions & 2 deletions tools/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ type PullRequestDetails struct {
AllActivityCount int

State string
LGTM bool
Prioritized bool
LGTM bool // lgtm
Prioritized bool // priority-important/soon or priority/critical-urgent
Stale bool // lifecycle/stake
}

// RuleFilter refers to a function that selects pull requests. A
Expand Down Expand Up @@ -98,13 +99,17 @@ func (s *Stats) process(pr *github.PullRequest) error {

lgtm := false
prioritized := false
stale := false
for _, label := range pr.Labels {
if *label.Name == "lgtm" {
lgtm = true
}
if *label.Name == "priority/important-soon" || *label.Name == "priority/critical-urgent" {
prioritized = true
}
if *label.Name == "lifecycle/stale" {
stale = true
}
}

details := &PullRequestDetails{
Expand All @@ -115,6 +120,7 @@ func (s *Stats) process(pr *github.PullRequest) error {
Reviews: reviews,
LGTM: lgtm,
Prioritized: prioritized,
Stale: stale,
}
if isMerged {
details.State = "merged"
Expand Down

0 comments on commit 6582232

Please sign in to comment.