Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1646)

Unified Diff: milo/appengine/common/funcs.go

Issue 2931773004: Milo: Add machine pool info for buildbot builder view. (Closed)
Patch Set: Review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/buildbot/pubsub_test.go ('k') | milo/appengine/frontend/buildbot_data.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/common/funcs.go
diff --git a/milo/appengine/common/funcs.go b/milo/appengine/common/funcs.go
index 805ebeadc536ed3b63c0c54e330fbee212f13998..36855445d18ed29ce6cd47bd5e1bb6d15fbb0cc9 100644
--- a/milo/appengine/common/funcs.go
+++ b/milo/appengine/common/funcs.go
@@ -31,6 +31,7 @@ var funcMap = template.FuncMap{
"consoleHeader": consoleHeader,
"pagedURL": pagedURL,
"formatTime": formatTime,
+ "percent": percent,
}
// localTime returns a <span> element with t in human format
@@ -245,6 +246,12 @@ func pagedURL(r *http.Request, limit int, cursor string) string {
return result.String()
}
+// percent divides one number by a divisor and returns the percentage in string form.
+func percent(numerator, divisor int) string {
+ p := float64(numerator) * 100.0 / float64(divisor)
+ return fmt.Sprintf("%.1f", p)
+}
+
func init() {
linkifySetTemplate = template.Must(
template.New("linkifySet").
« no previous file with comments | « milo/appengine/buildbot/pubsub_test.go ('k') | milo/appengine/frontend/buildbot_data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698