From 6e960f19728dfb46782833ae5d7312876807040a Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 9 Jun 2016 11:55:05 +0200 Subject: [PATCH] Less rounding in feature list --- cmd/ursrv/main.go | 6 +++--- static/index.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/ursrv/main.go b/cmd/ursrv/main.go index b30474217..cfe12c4c7 100644 --- a/cmd/ursrv/main.go +++ b/cmd/ursrv/main.go @@ -468,7 +468,7 @@ type category struct { type feature struct { Key string - Pct int + Pct float64 } func getReport(db *sql.DB) map[string]interface{} { @@ -488,7 +488,7 @@ func getReport(db *sql.DB) map[string]interface{} { var builders []string v2Reports := 0 - features := map[string]int{ + features := map[string]float64{ "Rate limiting": 0, "Upgrades allowed (automatic)": 0, "Upgrades allowed (manual)": 0, @@ -725,7 +725,7 @@ func getReport(db *sql.DB) map[string]interface{} { for _, key := range featureNames { featureList = append(featureList, feature{ Key: key, - Pct: (100 * features[key]) / v2Reports, + Pct: (100 * features[key]) / float64(v2Reports), }) } sort.Sort(sort.Reverse(sortableFeatureList(featureList))) diff --git a/static/index.html b/static/index.html index 662823748..d4ec153c0 100644 --- a/static/index.html +++ b/static/index.html @@ -266,9 +266,9 @@ found in the LICENSE file. {{range .features}} {{.Key}} - {{.Pct}}% + {{if ge .Pct 10.0}}{{.Pct | printf "%.0f"}}{{else if ge .Pct 1.0}}{{.Pct | printf "%.01f"}}{{else}}{{.Pct | printf "%.02f"}}{{end}}% -
+
{{end}}