mirror of
https://github.com/golang/go
synced 2024-11-25 05:38:01 -07:00
misc/dashboard/codereview: more abbreviated modification duration.
R=golang-dev, r CC=golang-dev https://golang.org/cl/6131044
This commit is contained in:
parent
0175e3f1e0
commit
1a79053725
@ -47,9 +47,9 @@ type CL struct {
|
|||||||
Reviewer string
|
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.
|
// 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 {
|
if p, ok := emailToPerson[cl.Owner]; ok {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
@ -79,13 +79,20 @@ func (cl *CL) LGTMHTML() template.HTML {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cl *CL) ModifiedAgo() string {
|
func (cl *CL) ModifiedAgo() string {
|
||||||
d := time.Now().Sub(cl.Modified)
|
// Just the first non-zero unit.
|
||||||
d -= d % time.Minute // truncate to minute resolution
|
units := map[string]time.Duration{
|
||||||
s := d.String()
|
"d": 24 * time.Hour,
|
||||||
if strings.HasSuffix(s, "0s") {
|
"h": time.Hour,
|
||||||
s = s[:len(s)-2]
|
"m": time.Minute,
|
||||||
|
"s": time.Second,
|
||||||
}
|
}
|
||||||
return s
|
d := time.Now().Sub(cl.Modified)
|
||||||
|
for suffix, u := range units {
|
||||||
|
if d > u {
|
||||||
|
return fmt.Sprintf("%d%s", d/u, suffix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "just now"
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAssign(w http.ResponseWriter, r *http.Request) {
|
func handleAssign(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -192,7 +192,7 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{
|
|||||||
<table class="cls">
|
<table class="cls">
|
||||||
{{range $cl := .CLs}}
|
{{range $cl := .CLs}}
|
||||||
<tr id="cl-{{$cl.Number}}">
|
<tr id="cl-{{$cl.Number}}">
|
||||||
<td class="email">{{$cl.ShortOwner}}</td>
|
<td class="email">{{$cl.DisplayOwner}}</td>
|
||||||
{{if $tbl.Assignable}}
|
{{if $tbl.Assignable}}
|
||||||
<td>
|
<td>
|
||||||
<select id="cl-rev-{{$cl.Number}}" {{if not $.UserIsReviewer}}disabled{{end}}>
|
<select id="cl-rev-{{$cl.Number}}" {{if not $.UserIsReviewer}}disabled{{end}}>
|
||||||
|
Loading…
Reference in New Issue
Block a user