Commit 24cce5c6 authored by David Symonds's avatar David Symonds

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
parent a0f7c6c6
...@@ -16,7 +16,7 @@ handlers: ...@@ -16,7 +16,7 @@ handlers:
- url: /_ah/queue/go/delay - url: /_ah/queue/go/delay
script: _go_app script: _go_app
login: admin login: admin
- url: /update-cl - url: /(gc|update-cl)
script: _go_app script: _go_app
login: admin login: admin
- url: /.* - url: /.*
......
...@@ -80,16 +80,19 @@ func (cl *CL) LGTMHTML() template.HTML { ...@@ -80,16 +80,19 @@ func (cl *CL) LGTMHTML() template.HTML {
func (cl *CL) ModifiedAgo() string { func (cl *CL) ModifiedAgo() string {
// Just the first non-zero unit. // Just the first non-zero unit.
units := map[string]time.Duration{ units := [...]struct {
"d": 24 * time.Hour, suffix string
"h": time.Hour, unit time.Duration
"m": time.Minute, }{
"s": time.Second, {"d", 24 * time.Hour},
{"h", time.Hour},
{"m", time.Minute},
{"s", time.Second},
} }
d := time.Now().Sub(cl.Modified) d := time.Now().Sub(cl.Modified)
for suffix, u := range units { for _, u := range units {
if d > u { if d > u.unit {
return fmt.Sprintf("%d%s", d/u, suffix) return fmt.Sprintf("%d%s", d/u.unit, u.suffix)
} }
} }
return "just now" return "just now"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment