From: David Symonds Date: Fri, 27 Apr 2012 23:47:15 +0000 (+1000) Subject: misc/dashboard/codereview: don't depend on map iteration order for unit calculation. X-Git-Tag: go1.1rc2~3286 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=24cce5c60c1cfc66567bf11203671e004c028c8d;p=gostls13.git misc/dashboard/codereview: don't depend on map iteration order for unit calculation. Fix auth requirements for /gc endpoint too. R=golang-dev, r CC=golang-dev https://golang.org/cl/6133049 --- diff --git a/misc/dashboard/codereview/app.yaml b/misc/dashboard/codereview/app.yaml index 33592a45c4..372eca5a15 100644 --- a/misc/dashboard/codereview/app.yaml +++ b/misc/dashboard/codereview/app.yaml @@ -16,7 +16,7 @@ handlers: - url: /_ah/queue/go/delay script: _go_app login: admin -- url: /update-cl +- url: /(gc|update-cl) script: _go_app login: admin - url: /.* diff --git a/misc/dashboard/codereview/dashboard/cl.go b/misc/dashboard/codereview/dashboard/cl.go index e427176109..80493aa5bd 100644 --- a/misc/dashboard/codereview/dashboard/cl.go +++ b/misc/dashboard/codereview/dashboard/cl.go @@ -80,16 +80,19 @@ 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, + units := [...]struct { + suffix string + unit time.Duration + }{ + {"d", 24 * time.Hour}, + {"h", time.Hour}, + {"m", time.Minute}, + {"s", time.Second}, } d := time.Now().Sub(cl.Modified) - for suffix, u := range units { - if d > u { - return fmt.Sprintf("%d%s", d/u, suffix) + for _, u := range units { + if d > u.unit { + return fmt.Sprintf("%d%s", d/u.unit, u.suffix) } } return "just now"