Commit 3cc9d167 authored by David Symonds's avatar David Symonds

misc/dashboard/codereview: recognize "NOT LGTM".

A "NOT LGTM" overrules a previous "LGTM" by the same person, and vice versa.
"NOT LGTM"s are shown in the same location as LGTMs, colored red.

R=rsc
CC=golang-dev
https://golang.org/cl/6453062
parent f8c6514a
...@@ -49,6 +49,7 @@ type CL struct { ...@@ -49,6 +49,7 @@ type CL struct {
Description []byte `datastore:",noindex"` Description []byte `datastore:",noindex"`
FirstLine string `datastore:",noindex"` FirstLine string `datastore:",noindex"`
LGTMs []string LGTMs []string
NotLGTMs []string
// Mail information. // Mail information.
Subject string `datastore:",noindex"` Subject string `datastore:",noindex"`
...@@ -78,9 +79,9 @@ func (cl *CL) FirstLineHTML() template.HTML { ...@@ -78,9 +79,9 @@ func (cl *CL) FirstLineHTML() template.HTML {
return template.HTML(s) return template.HTML(s)
} }
func (cl *CL) LGTMHTML() template.HTML { func formatEmails(e []string) template.HTML {
x := make([]string, len(cl.LGTMs)) x := make([]string, len(e))
for i, s := range cl.LGTMs { for i, s := range e {
s = template.HTMLEscapeString(s) s = template.HTMLEscapeString(s)
if !strings.Contains(s, "@") { if !strings.Contains(s, "@") {
s = "<b>" + s + "</b>" s = "<b>" + s + "</b>"
...@@ -91,6 +92,14 @@ func (cl *CL) LGTMHTML() template.HTML { ...@@ -91,6 +92,14 @@ func (cl *CL) LGTMHTML() template.HTML {
return template.HTML(strings.Join(x, ", ")) return template.HTML(strings.Join(x, ", "))
} }
func (cl *CL) LGTMHTML() template.HTML {
return formatEmails(cl.LGTMs)
}
func (cl *CL) NotLGTMHTML() template.HTML {
return formatEmails(cl.NotLGTMs)
}
func (cl *CL) ModifiedAgo() string { func (cl *CL) ModifiedAgo() string {
// Just the first non-zero unit. // Just the first non-zero unit.
units := [...]struct { units := [...]struct {
...@@ -326,6 +335,7 @@ func updateCL(c appengine.Context, n string) error { ...@@ -326,6 +335,7 @@ func updateCL(c appengine.Context, n string) error {
cl.FirstLine = cl.FirstLine[:i] cl.FirstLine = cl.FirstLine[:i]
} }
lgtm := make(map[string]bool) lgtm := make(map[string]bool)
notLGTM := make(map[string]bool)
rcpt := make(map[string]bool) rcpt := make(map[string]bool)
for _, msg := range apiResp.Messages { for _, msg := range apiResp.Messages {
s, rev := msg.Sender, false s, rev := msg.Sender, false
...@@ -343,6 +353,11 @@ func updateCL(c appengine.Context, n string) error { ...@@ -343,6 +353,11 @@ func updateCL(c appengine.Context, n string) error {
if msg.Approval { if msg.Approval {
lgtm[s] = true lgtm[s] = true
delete(notLGTM, s) // "LGTM" overrules previous "NOT LGTM"
}
if strings.Contains(msg.Text, "NOT LGTM") {
notLGTM[s] = true
delete(lgtm, s) // "NOT LGTM" overrules previous "LGTM"
} }
for _, r := range msg.Recipients { for _, r := range msg.Recipients {
...@@ -352,10 +367,14 @@ func updateCL(c appengine.Context, n string) error { ...@@ -352,10 +367,14 @@ func updateCL(c appengine.Context, n string) error {
for l := range lgtm { for l := range lgtm {
cl.LGTMs = append(cl.LGTMs, l) cl.LGTMs = append(cl.LGTMs, l)
} }
for l := range notLGTM {
cl.NotLGTMs = append(cl.NotLGTMs, l)
}
for r := range rcpt { for r := range rcpt {
cl.Recipients = append(cl.Recipients, r) cl.Recipients = append(cl.Recipients, r)
} }
sort.Strings(cl.LGTMs) sort.Strings(cl.LGTMs)
sort.Strings(cl.NotLGTMs)
sort.Strings(cl.Recipients) sort.Strings(cl.Recipients)
err = datastore.RunInTransaction(c, func(c appengine.Context) error { err = datastore.RunInTransaction(c, func(c appengine.Context) error {
......
...@@ -245,6 +245,7 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{ ...@@ -245,6 +245,7 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{
<td> <td>
<a href="http://codereview.appspot.com/{{.Number}}/" title="{{ printf "%s" .Description}}">{{.Number}}: {{.FirstLineHTML}}</a> <a href="http://codereview.appspot.com/{{.Number}}/" title="{{ printf "%s" .Description}}">{{.Number}}: {{.FirstLineHTML}}</a>
{{if and .LGTMs $tbl.Assignable}}<br /><span style="font-size: smaller;">LGTMs: {{.LGTMHTML}}{{end}}</span> {{if and .LGTMs $tbl.Assignable}}<br /><span style="font-size: smaller;">LGTMs: {{.LGTMHTML}}{{end}}</span>
{{if and .NotLGTMs $tbl.Assignable}}<br /><span style="font-size: smaller; color: #f74545;">NOT LGTMs: {{.NotLGTMHTML}}{{end}}</span>
</td> </td>
<td title="Last modified">{{.ModifiedAgo}}</td> <td title="Last modified">{{.ModifiedAgo}}</td>
{{if $.IsAdmin}}<td><a href="/update-cl?cl={{.Number}}" title="Update this CL">&#x27f3;</a></td>{{end}} {{if $.IsAdmin}}<td><a href="/update-cl?cl={{.Number}}" title="Update this CL">&#x27f3;</a></td>{{end}}
......
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