diff --git a/cmd/ursrv/analytics.go b/cmd/ursrv/analytics.go index 0e802a06c..00261a8ca 100644 --- a/cmd/ursrv/analytics.go +++ b/cmd/ursrv/analytics.go @@ -145,7 +145,7 @@ func statsForFloats(data []float64) [4]float64 { return res } -func group(by func(string) string, as []analytic, perGroup int) []analytic { +func group(by func(string) string, as []analytic, perGroup int, otherPct float64) []analytic { var res []analytic next: @@ -170,6 +170,25 @@ next: } sort.Sort(analyticList(res)) + + if otherPct > 0 { + // Groups with less than otherPCt go into "Other" + other := analytic{ + Key: "Other", + } + for i := 0; i < len(res); i++ { + if res[i].Percentage < otherPct || res[i].Key == "Other" { + other.Count += res[i].Count + other.Percentage += res[i].Percentage + res = append(res[:i], res[i+1:]...) + i-- + } + } + if other.Count > 0 { + res = append(res, other) + } + } + return res } diff --git a/cmd/ursrv/main.go b/cmd/ursrv/main.go index 7a2d3d33f..c69559464 100644 --- a/cmd/ursrv/main.go +++ b/cmd/ursrv/main.go @@ -892,10 +892,10 @@ func getReport(db *sql.DB) map[string]interface{} { r["nodes"] = nodes r["versionNodes"] = reports r["categories"] = categories - r["versions"] = group(byVersion, analyticsFor(versions, 2000), 10) + r["versions"] = group(byVersion, analyticsFor(versions, 2000), 5, 1.0) r["versionPenetrations"] = penetrationLevels(analyticsFor(versions, 2000), []float64{50, 75, 90, 95}) - r["platforms"] = group(byPlatform, analyticsFor(platforms, 2000), 10) - r["compilers"] = group(byCompiler, analyticsFor(compilers, 2000), 5) + r["platforms"] = group(byPlatform, analyticsFor(platforms, 2000), 10, 0.0) + r["compilers"] = group(byCompiler, analyticsFor(compilers, 2000), 5, 1.0) r["builders"] = analyticsFor(builders, 12) r["distributions"] = analyticsFor(distributions, len(knownDistributions)) r["featureOrder"] = featureOrder