Commit fe252584 authored by David Symonds's avatar David Symonds

misc/dashboard/codereview: simplify parallel operations for front page, and capture timing info.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6128044
parent f72c828c
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"io" "io"
"net/http" "net/http"
"sync" "sync"
"time"
"appengine" "appengine"
"appengine/datastore" "appengine/datastore"
...@@ -34,42 +35,42 @@ func handleFront(w http.ResponseWriter, r *http.Request) { ...@@ -34,42 +35,42 @@ func handleFront(w http.ResponseWriter, r *http.Request) {
Filter("Closed =", false). Filter("Closed =", false).
Order("-Modified") Order("-Modified")
if data.UserIsReviewer { tableFetch := func(index int, f func(tbl *clTable) error) {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
tbl := &data.Tables[0] start := time.Now()
q := activeCLs.Filter("Reviewer =", currentPerson).Limit(10) if err := f(&data.Tables[index]); err != nil {
tbl.Title = "CLs assigned to you for review"
tbl.Assignable = true
if _, err := q.GetAll(c, &tbl.CLs); err != nil {
errc <- err errc <- err
} }
data.Timing[index] = time.Now().Sub(start)
}() }()
} }
wg.Add(1) if data.UserIsReviewer {
go func() { tableFetch(0, func(tbl *clTable) error {
defer wg.Done() q := activeCLs.Filter("Reviewer =", currentPerson).Limit(10)
tbl := &data.Tables[1] tbl.Title = "CLs assigned to you for review"
tbl.Assignable = true
_, err := q.GetAll(c, &tbl.CLs)
return err
})
}
tableFetch(1, func(tbl *clTable) error {
q := activeCLs.Filter("Author =", currentPerson).Limit(10) q := activeCLs.Filter("Author =", currentPerson).Limit(10)
tbl.Title = "CLs sent by you" tbl.Title = "CLs sent by you"
tbl.Assignable = true tbl.Assignable = true
if _, err := q.GetAll(c, &tbl.CLs); err != nil { _, err := q.GetAll(c, &tbl.CLs)
errc <- err return err
} })
}()
wg.Add(1) tableFetch(2, func(tbl *clTable) error {
go func() {
defer wg.Done()
tbl := &data.Tables[2]
q := activeCLs.Limit(50) q := activeCLs.Limit(50)
tbl.Title = "Other active CLs" tbl.Title = "Other active CLs"
tbl.Assignable = true tbl.Assignable = true
if _, err := q.GetAll(c, &tbl.CLs); err != nil { if _, err := q.GetAll(c, &tbl.CLs); err != nil {
errc <- err return err
return
} }
// filter // filter
if data.UserIsReviewer { if data.UserIsReviewer {
...@@ -81,22 +82,19 @@ func handleFront(w http.ResponseWriter, r *http.Request) { ...@@ -81,22 +82,19 @@ func handleFront(w http.ResponseWriter, r *http.Request) {
} }
} }
} }
}() return nil
})
wg.Add(1) tableFetch(3, func(tbl *clTable) error {
go func() {
defer wg.Done()
tbl := &data.Tables[3]
q := datastore.NewQuery("CL"). q := datastore.NewQuery("CL").
Filter("Closed =", true). Filter("Closed =", true).
Order("-Modified"). Order("-Modified").
Limit(10) Limit(10)
tbl.Title = "Recently closed CLs" tbl.Title = "Recently closed CLs"
tbl.Assignable = false tbl.Assignable = false
if _, err := q.GetAll(c, &tbl.CLs); err != nil { _, err := q.GetAll(c, &tbl.CLs)
errc <- err return err
} })
}()
wg.Wait() wg.Wait()
...@@ -119,6 +117,7 @@ func handleFront(w http.ResponseWriter, r *http.Request) { ...@@ -119,6 +117,7 @@ func handleFront(w http.ResponseWriter, r *http.Request) {
type frontPageData struct { type frontPageData struct {
Tables [4]clTable Tables [4]clTable
Timing [4]time.Duration
Reviewers []string Reviewers []string
UserIsReviewer bool UserIsReviewer bool
...@@ -175,6 +174,10 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{ ...@@ -175,6 +174,10 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{
color: blue; color: blue;
text-decoration: none; /* no link underline */ text-decoration: none; /* no link underline */
} }
address {
font-size: 10px;
text-align: right;
}
.email { .email {
font-family: monospace; font-family: monospace;
} }
...@@ -235,6 +238,11 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{ ...@@ -235,6 +238,11 @@ var frontPage = template.Must(template.New("front").Funcs(template.FuncMap{
{{end}} {{end}}
{{end}} {{end}}
<hr />
<address>
datastore timing: {{range .Timing}} {{.}}{{end}}
</address>
</body> </body>
</html> </html>
`)) `))
...@@ -4,10 +4,10 @@ package dashboard ...@@ -4,10 +4,10 @@ package dashboard
import ( import (
"net/http" "net/http"
"time"
"appengine" "appengine"
"appengine/datastore" "appengine/datastore"
"time"
) )
func init() { func init() {
......
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