]> Cypherpunks repositories - gostls13.git/commitdiff
misc/dashboard/codereview: don't depend on map iteration order for unit calculation.
authorDavid Symonds <dsymonds@golang.org>
Fri, 27 Apr 2012 23:47:15 +0000 (09:47 +1000)
committerDavid Symonds <dsymonds@golang.org>
Fri, 27 Apr 2012 23:47:15 +0000 (09:47 +1000)
Fix auth requirements for /gc endpoint too.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6133049

misc/dashboard/codereview/app.yaml
misc/dashboard/codereview/dashboard/cl.go

index 33592a45c43211aad9fd8fb930e6461089c77b1e..372eca5a155fa18e2f930d758c71ddf77b64f9f9 100644 (file)
@@ -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: /.*
index e427176109fa6065b1a2dbeac82ae191f60a1483..80493aa5bdae54828920524ee8231ac559058893 100644 (file)
@@ -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/usuffix)
+       for _, u := range units {
+               if d > u.unit {
+                       return fmt.Sprintf("%d%s", d/u.unit, u.suffix)
                }
        }
        return "just now"