From: David Symonds Date: Fri, 27 Apr 2012 07:12:09 +0000 (+1000) Subject: misc/dashboard/codereview: more abbreviated modification duration. X-Git-Tag: go1.1rc2~3291 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1a7905372536154661b094accadcbc1e692b1544;p=gostls13.git misc/dashboard/codereview: more abbreviated modification duration. R=golang-dev, r CC=golang-dev https://golang.org/cl/6131044 --- diff --git a/misc/dashboard/codereview/dashboard/cl.go b/misc/dashboard/codereview/dashboard/cl.go index a023ff6ab8..e427176109 100644 --- a/misc/dashboard/codereview/dashboard/cl.go +++ b/misc/dashboard/codereview/dashboard/cl.go @@ -47,9 +47,9 @@ type CL struct { Reviewer string } -// ShortOwner returns the CL's owner, either as their email address +// DisplayOwner returns the CL's owner, either as their email address // or the person ID if it's a reviewer. It is for display only. -func (cl *CL) ShortOwner() string { +func (cl *CL) DisplayOwner() string { if p, ok := emailToPerson[cl.Owner]; ok { return p } @@ -79,13 +79,20 @@ func (cl *CL) LGTMHTML() template.HTML { } func (cl *CL) ModifiedAgo() string { + // Just the first non-zero unit. + units := map[string]time.Duration{ + "d": 24 * time.Hour, + "h": time.Hour, + "m": time.Minute, + "s": time.Second, + } d := time.Now().Sub(cl.Modified) - d -= d % time.Minute // truncate to minute resolution - s := d.String() - if strings.HasSuffix(s, "0s") { - s = s[:len(s)-2] + for suffix, u := range units { + if d > u { + return fmt.Sprintf("%d%s", d/u, suffix) + } } - return s + return "just now" } func handleAssign(w http.ResponseWriter, r *http.Request) { diff --git a/misc/dashboard/codereview/dashboard/front.go b/misc/dashboard/codereview/dashboard/front.go index efdfe29467..a687e85966 100644 --- a/misc/dashboard/codereview/dashboard/front.go +++ b/misc/dashboard/codereview/dashboard/front.go @@ -192,7 +192,7 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{ {{range $cl := .CLs}} - + {{if $tbl.Assignable}}