x/build/devapp: put performance issues in their own grouping

Separate performance issues (those with the "Performance" label) from
the rest of the issues on the release dashboard. Performance issues
tend to be those which are not critical to fix for any particular
release, so separating them and putting them later in order helps to
deprioritize them.

Kind of a hack, but it works.

Change-Id: I6fa0f85629504c298691b492e50e03c817c62a1b
Reviewed-on: https://go-review.googlesource.com/c/145937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/devapp/release.go b/devapp/release.go
index 53eef92..0b954c2 100644
--- a/devapp/release.go
+++ b/devapp/release.go
@@ -80,8 +80,9 @@
 }
 
 type item struct {
-	Issue *maintner.GitHubIssue
-	CLs   []*gerritCL
+	Issue            *maintner.GitHubIssue
+	CLs              []*gerritCL
+	FirstPerformance bool // set if this item is the first item which is labeled "performance"
 }
 
 func (i *item) ReleaseBlocker() bool {
@@ -93,9 +94,18 @@
 
 type itemsBySummary []item
 
-func (x itemsBySummary) Len() int           { return len(x) }
-func (x itemsBySummary) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
-func (x itemsBySummary) Less(i, j int) bool { return itemSummary(x[i]) < itemSummary(x[j]) }
+func (x itemsBySummary) Len() int      { return len(x) }
+func (x itemsBySummary) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
+func (x itemsBySummary) Less(i, j int) bool {
+	// Sort performance issues to the end.
+	pi := x[i].Issue != nil && x[i].Issue.HasLabel("Performance")
+	pj := x[j].Issue != nil && x[j].Issue.HasLabel("Performance")
+	if pi != pj {
+		return !pi
+	}
+	// Otherwise sort by the item summary.
+	return itemSummary(x[i]) < itemSummary(x[j])
+}
 
 func itemSummary(it item) string {
 	if it.Issue != nil {
@@ -265,6 +275,12 @@
 				continue
 			}
 			sort.Sort(itemsBySummary(items))
+			for idx := range items {
+				if items[idx].Issue.HasLabel("Performance") {
+					items[idx].FirstPerformance = true
+					break
+				}
+			}
 			issueGroups = append(issueGroups, group{
 				Dir:   d,
 				Items: items,
diff --git a/devapp/templates/release.tmpl b/devapp/templates/release.tmpl
index 02f330b..1fe71ce 100644
--- a/devapp/templates/release.tmpl
+++ b/devapp/templates/release.tmpl
@@ -31,6 +31,9 @@
 .Section-title {
   margin: .5em 0;
 }
+.Performance-separator {
+  margin-left:4ch;
+}
 .Item {
   display: flex;
 }
@@ -62,6 +65,7 @@
     {{range .Groups}}
       {{if .Dir}}<h4 class="DirTitle">{{.Dir}}</h4>{{end}}
       {{range .Items}}
+	{{if .FirstPerformance}}<h5 class="Performance-separator">performance</h5>{{end}}
         {{$i := .Issue}}
         {{if $i}}
           <div class="Item{{if .ReleaseBlocker}} Item-blocker{{end}}">