From 948edf8055be2275a7c051e49cd38223517f98be Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 1 Dec 2017 15:16:13 +0100 Subject: dashboard/app: cosmetic changes to manager stats --- dashboard/app/api.go | 4 +-- dashboard/app/handler.go | 30 ++++++++++++++-- dashboard/app/main.go | 4 +++ dashboard/app/main.html | 81 ++++++++++++++++++------------------------ dashboard/app/static/style.css | 19 +++++----- 5 files changed, 76 insertions(+), 62 deletions(-) diff --git a/dashboard/app/api.go b/dashboard/app/api.go index ef1f344fd..cab952561 100644 --- a/dashboard/app/api.go +++ b/dashboard/app/api.go @@ -573,7 +573,7 @@ func apiReportFailedRepro(c context.Context, ns string, r *http.Request) (interf return nil, err } if bug == nil { - return nil, fmt.Errorf("can't find bug for this crash") + return nil, fmt.Errorf("%v: can't find bug for crash %q", ns, req.Title) } tx := func(c context.Context) error { bug := new(Bug) @@ -613,7 +613,7 @@ func apiNeedRepro(c context.Context, ns string, r *http.Request) (interface{}, e return nil, err } if bug == nil { - return nil, fmt.Errorf("can't find bug for this crash") + return nil, fmt.Errorf("%v: can't find bug for crash %q", ns, req.Title) } resp := &dashapi.NeedReproResp{ NeedRepro: needRepro(bug), diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go index ef8cec133..91d0210c7 100644 --- a/dashboard/app/handler.go +++ b/dashboard/app/handler.go @@ -92,10 +92,25 @@ func formatDuration(d time.Duration) string { days := int(d / (24 * time.Hour)) hours := int(d / time.Hour % 24) mins := int(d / time.Minute % 60) - if days != 0 { - return fmt.Sprintf("%vd%vh", days, hours) + if days >= 10 { + return fmt.Sprintf("%vd", days) + } else if days != 0 { + return fmt.Sprintf("%vd%02vh", days, hours) + } else if hours != 0 { + return fmt.Sprintf("%vh%02vm", hours, mins) } - return fmt.Sprintf("%vh%vm", hours, mins) + return fmt.Sprintf("%vm", mins) +} + +func formatLateness(now, t time.Time) string { + if t.IsZero() { + return "never" + } + d := now.Sub(t) + if d < 5*time.Minute { + return "now" + } + return formatDuration(d) } func formatReproLevel(l dashapi.ReproLevel) string { @@ -109,6 +124,13 @@ func formatReproLevel(l dashapi.ReproLevel) string { } } +func formatStat(v int64) string { + if v == 0 { + return "" + } + return fmt.Sprint(v) +} + var ( templates = template.Must(template.New("").Funcs(templateFuncs).ParseGlob("*.html")) @@ -116,6 +138,8 @@ var ( "formatTime": formatTime, "formatClock": formatClock, "formatDuration": formatDuration, + "formatLateness": formatLateness, "formatReproLevel": formatReproLevel, + "formatStat": formatStat, } ) diff --git a/dashboard/app/main.go b/dashboard/app/main.go index cb66a28ba..70e5f05b6 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -28,6 +28,7 @@ func init() { type uiMain struct { Header *uiHeader + Now time.Time Log []byte Managers []*uiManager Jobs []*uiJob @@ -73,6 +74,7 @@ type uiBug struct { Namespace string Title string NumCrashes int64 + NumCrashesBad bool FirstTime time.Time LastTime time.Time ReproLevel dashapi.ReproLevel @@ -144,6 +146,7 @@ func handleMain(c context.Context, w http.ResponseWriter, r *http.Request) error } data := &uiMain{ Header: h, + Now: timeNow(c), Log: errorLog, Managers: managers, Jobs: jobs, @@ -259,6 +262,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers [] Namespace: bug.Namespace, Title: bug.displayTitle(), NumCrashes: bug.NumCrashes, + NumCrashesBad: bug.NumCrashes >= 10000 && timeNow(c).Sub(bug.LastTime) < 24*time.Hour, FirstTime: bug.FirstTime, LastTime: bug.LastTime, ReproLevel: bug.ReproLevel, diff --git a/dashboard/app/main.html b/dashboard/app/main.html index 7a6e8ae05..6a9c84f75 100644 --- a/dashboard/app/main.html +++ b/dashboard/app/main.html @@ -1,27 +1,3 @@ -{{define "bug_table"}} - - - - - - - - - - - {{range $b := $.Bugs}} - - - - - - - - - {{end}} -
{{.Namespace}} ({{len $.Bugs}}):
TitleCountReproLastStatusPatched
{{$b.Title}}{{$b.NumCrashes}}{{formatReproLevel $b.ReproLevel}}{{formatTime $b.LastTime}}{{if $b.Link}}{{$b.Status}}{{else}}{{$b.Status}}{{end}}{{if $b.Commits}}{{len $b.PatchedOn}}/{{len $b.MissingOn}}{{end}}
-{{end}} - @@ -45,38 +21,30 @@ Name Last Active Current Build - Failed Build - Today: Uptime - Fuzzing Time + Current Uptime + Today: Fuzzing Time Corpus Coverage Crashes Execs + Failed Build {{range $mgr := $.Managers}} {{$mgr.Namespace}}/{{$mgr.Name}} - {{if $mgr.LastActiveBad}} - {{formatTime $mgr.LastActive}} - {{else}} - {{formatClock $mgr.LastActive}} - {{end}} + {{formatLateness $.Now $mgr.LastActive}} {{if $mgr.CurrentBuild}} - {{formatTime $mgr.CurrentBuild.Time}} - {{else}} - - {{end}} - {{if $mgr.FailedBuildBugLink}} - failed + {{formatLateness $.Now $mgr.CurrentBuild.Time}} {{else}} {{end}} - {{formatDuration $mgr.CurrentUpTime}} - {{formatDuration $mgr.TotalFuzzingTime}} - {{$mgr.MaxCorpus}} - {{$mgr.MaxCover}} - {{$mgr.TotalCrashes}} - {{$mgr.TotalExecs}} + {{formatDuration $mgr.CurrentUpTime}} + {{formatDuration $mgr.TotalFuzzingTime}} + {{formatStat $mgr.MaxCorpus}} + {{formatStat $mgr.MaxCover}} + {{formatStat $mgr.TotalCrashes}} + {{formatStat $mgr.TotalExecs}} + {{if $mgr.FailedBuildBugLink}}bug{{end}} {{end}} @@ -132,8 +100,29 @@

- {{range $g := $.BugGroups}} - {{template "bug_table" $g}}
+ {{range $group := $.BugGroups}} + + + + + + + + + + + {{range $b := $group.Bugs}} + + + + + + + + + {{end}} +
{{.Namespace}} ({{len $group.Bugs}}):
TitleCountReproLastStatusPatched
{{$b.Title}}{{$b.NumCrashes}}{{formatReproLevel $b.ReproLevel}}{{formatLateness $.Now $b.LastTime}}{{if $b.Link}}{{$b.Status}}{{else}}{{$b.Status}}{{end}}{{if $b.Commits}}{{len $b.PatchedOn}}/{{len $b.MissingOn}}{{end}}
+

{{end}} diff --git a/dashboard/app/static/style.css b/dashboard/app/static/style.css index 98bf1913b..5ef180b99 100644 --- a/dashboard/app/static/style.css +++ b/dashboard/app/static/style.css @@ -77,10 +77,6 @@ table td, table th { max-width: 400pt; } -.list_table .count { - text-align: right; -} - .list_table .tag { font-family: monospace; font-size: 8pt; @@ -112,13 +108,14 @@ table td, table th { max-width: 300pt; } -.button { - color: #222; - border: 1px solid #375EAB; - background: #E0EBF5; - border-radius: 3px; - cursor: pointer; - margin-left: 10px; +.list_table .stat { + font-family: monospace; + text-align: right; +} + +.bad { + color: #f00; + font-weight: bold; } textarea { -- cgit mrf-deployment