Skip to content

Commit 049da80

Browse files
dmitshurgopherbot
authored andcommitted
devapp: account {,de}milestoned events in issue burndown chart
Previously the calculation of open issues over previous days only took into account when the issue was created and closed, but not that issues may have been added to or removed from the current development milestone over their lifetime. This was especially noticeable when relui moved 100 open issues from Go1.21 to Go1.22, yet the burndown graph made it seem like there had always been around 225 issues in it, pretty misleading. :( maintner already tracks milestoned and demilestoned events along with event creation time, so take them into account to de-gaslight the graph. Change-Id: Iba3f3f68e4ddc140d5612317c02bdfefe4693d8d Reviewed-on: https://go-review.googlesource.com/c/build/+/517716 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent b316f91 commit 049da80

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed

devapp/release.go

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"bytes"
99
"encoding/json"
10+
"errors"
1011
"fmt"
1112
"html/template"
1213
"log"
@@ -265,22 +266,12 @@ func (s *server) updateReleaseData() {
265266
curMilestoneStart := time.Date(2021, time.August+monthsSinceGo117Release, 1, 0, 0, 0, 0, time.UTC)
266267

267268
dirToIssues := map[string][]*maintner.GitHubIssue{}
268-
var curMilestoneIssues []*maintner.GitHubIssue
269269
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
270-
// Only include issues in active milestones.
271-
if issue.Milestone.IsUnknown() || issue.Milestone.Closed || issue.Milestone.IsNone() {
272-
return nil
273-
}
274-
275-
if issue.Milestone.Title == curMilestoneTitle {
276-
curMilestoneIssues = append(curMilestoneIssues, issue)
277-
}
278-
279-
// Only open issues are displayed on the page using dirToIssues.
280-
if issue.Closed {
270+
// Only open issues in active milestones are displayed on the page using dirToIssues.
271+
if issue.Closed ||
272+
issue.Milestone.IsUnknown() || issue.Milestone.Closed || issue.Milestone.IsNone() {
281273
return nil
282274
}
283-
284275
dirs := titleDirs(issue.Title)
285276
if len(dirs) == 0 {
286277
dirToIssues[""] = append(dirToIssues[""], issue)
@@ -292,13 +283,52 @@ func (s *server) updateReleaseData() {
292283
return nil
293284
})
294285

286+
// Find issues that have been in the current milestone.
287+
var curMilestoneIssues []*maintner.GitHubIssue
288+
s.repo.ForeachIssue(func(issue *maintner.GitHubIssue) error {
289+
if issue.Closed && issue.ClosedAt.Before(curMilestoneStart) {
290+
// Old issue, couldn't be relevant to current milestone.
291+
return nil
292+
}
293+
if !issue.Milestone.IsUnknown() && issue.Milestone.Title == curMilestoneTitle {
294+
// Easy case: the issue is still in current milestone.
295+
curMilestoneIssues = append(curMilestoneIssues, issue)
296+
return nil
297+
}
298+
// Check if the issue was ever in the current milestone.
299+
issue.ForeachEvent(func(e *maintner.GitHubIssueEvent) error {
300+
if e.Type == "milestoned" && e.Milestone == curMilestoneTitle {
301+
curMilestoneIssues = append(curMilestoneIssues, issue)
302+
return errStopIteration
303+
}
304+
return nil
305+
})
306+
return nil
307+
})
308+
295309
bd := burndownData{Milestone: curMilestoneTitle}
296310
for t, now := curMilestoneStart, time.Now(); t.Before(now); t = t.Add(24 * time.Hour) {
297311
var e burndownEntry
298312
for _, issue := range curMilestoneIssues {
299313
if issue.Created.After(t) || (issue.Closed && issue.ClosedAt.Before(t)) {
300314
continue
301315
}
316+
var inCurMilestoneAtT bool
317+
issue.ForeachEvent(func(e *maintner.GitHubIssueEvent) error {
318+
if e.Created.After(t) {
319+
return errStopIteration
320+
}
321+
switch e.Type {
322+
case "milestoned":
323+
inCurMilestoneAtT = e.Milestone == curMilestoneTitle
324+
case "demilestoned":
325+
inCurMilestoneAtT = false
326+
}
327+
return nil
328+
})
329+
if !inCurMilestoneAtT {
330+
continue
331+
}
302332
if issue.HasLabel("release-blocker") {
303333
e.Blockers++
304334
}
@@ -522,3 +552,7 @@ func (s *server) handleRelease(t *template.Template, w http.ResponseWriter, r *h
522552
return
523553
}
524554
}
555+
556+
// errStopIteration is used to stop iteration over issues or comments.
557+
// It has no special meaning.
558+
var errStopIteration = errors.New("stop iteration")

0 commit comments

Comments
 (0)