Skip to content

Commit

Permalink
dashboard: share invalid bug stats
Browse files Browse the repository at this point in the history
Show the number of bugs that were closed automatically, because of the
revoked repro, manually.
  • Loading branch information
a-nogikh committed Dec 20, 2022
1 parent 4791c8e commit d3e7670
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
46 changes: 39 additions & 7 deletions dashboard/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ type uiTerminalPage struct {
Header *uiHeader
Now time.Time
Bugs *uiBugGroup
Stats *uiBugStats
}

type uiBugStats struct {
Total int
AutoObsoleted int
ReproObsoleted int
UserObsoleted int
}

func (stats *uiBugStats) Record(bug *Bug, bugReporting *BugReporting) {
stats.Total++
switch bug.Status {
case BugStatusInvalid:
if bugReporting.Auto {
stats.AutoObsoleted++
} else {
stats.UserObsoleted++
}
if bug.StatusReason == dashapi.InvalidatedByRevokedRepro {
stats.ReproObsoleted++
}
}
}

type uiAdminPage struct {
Expand Down Expand Up @@ -279,6 +302,7 @@ func handleInvalid(c context.Context, w http.ResponseWriter, r *http.Request) er
Status: BugStatusInvalid,
Subpage: "/invalid",
ShowPatch: false,
ShowStats: true,
})
}

Expand All @@ -287,6 +311,7 @@ type TerminalBug struct {
Subpage string
ShowPatch bool
ShowPatched bool
ShowStats bool
}

func handleTerminalBugList(c context.Context, w http.ResponseWriter, r *http.Request, typ *TerminalBug) error {
Expand All @@ -305,14 +330,18 @@ func handleTerminalBugList(c context.Context, w http.ResponseWriter, r *http.Req
return err
}
}
bugs, err := fetchTerminalBugs(c, accessLevel, hdr.Namespace, manager, typ, extraBugs)
bugs, stats, err := fetchTerminalBugs(c, accessLevel, hdr.Namespace, manager, typ, extraBugs)
if err != nil {
return err
}
if !typ.ShowStats {
stats = nil
}
data := &uiTerminalPage{
Header: hdr,
Now: timeNow(c),
Bugs: bugs,
Stats: stats,
}
return serveTemplate(w, "terminal.html", data)
}
Expand Down Expand Up @@ -755,7 +784,7 @@ func loadVisibleBugs(c context.Context, accessLevel AccessLevel, ns, manager str
}

func fetchTerminalBugs(c context.Context, accessLevel AccessLevel,
ns, manager string, typ *TerminalBug, extraBugs []*Bug) (*uiBugGroup, error) {
ns, manager string, typ *TerminalBug, extraBugs []*Bug) (*uiBugGroup, *uiBugStats, error) {
bugs, _, err := loadAllBugs(c, func(query *db.Query) *db.Query {
query = query.Filter("Namespace=", ns).
Filter("Status=", typ.Status)
Expand All @@ -765,16 +794,16 @@ func fetchTerminalBugs(c context.Context, accessLevel AccessLevel,
return query
})
if err != nil {
return nil, err
return nil, nil, err
}
bugs = append(bugs, extraBugs...)
state, err := loadReportingState(c)
if err != nil {
return nil, err
return nil, nil, err
}
managers, err := managerList(c, ns)
if err != nil {
return nil, err
return nil, nil, err
}
sort.Slice(bugs, func(i, j int) bool {
iFixed := bugs[i].Status == BugStatusFixed
Expand All @@ -785,6 +814,7 @@ func fetchTerminalBugs(c context.Context, accessLevel AccessLevel,
}
return bugs[i].Closed.After(bugs[j].Closed)
})
stats := &uiBugStats{}
res := &uiBugGroup{
Now: timeNow(c),
ShowPatch: typ.ShowPatch,
Expand All @@ -795,9 +825,11 @@ func fetchTerminalBugs(c context.Context, accessLevel AccessLevel,
if accessLevel < bug.sanitizeAccess(accessLevel) {
continue
}
res.Bugs = append(res.Bugs, createUIBug(c, bug, state, managers))
uiBug := createUIBug(c, bug, state, managers)
res.Bugs = append(res.Bugs, uiBug)
stats.Record(bug, &bug.Reporting[uiBug.ReportingIndex])
}
return res, nil
return res, stats, nil
}

func loadDupsForBug(c context.Context, r *http.Request, bug *Bug, state *ReportingState, managers []string) (
Expand Down
7 changes: 7 additions & 0 deletions dashboard/app/terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<body>
{{template "header" .Header}}


{{if .Stats}}
{{with .Stats}}
Out of <b>{{.Total}}</b> bugs, <b>{{.AutoObsoleted}}</b> were automatically obsoleted (<b>{{.ReproObsoleted}}</b> due to revoked reproducers), <b>{{.UserObsoleted}}</b> were invalidated by users.<br />
{{end}}
{{end}}

{{template "bug_list" .Bugs}}
</body>
</html>

0 comments on commit d3e7670

Please sign in to comment.