aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2023-07-05 08:22:10 +0200
committerJakob Borg <jakob@kastelo.net>2023-07-05 08:22:10 +0200
commit25ec2b63abb4d43d37833acdc9cda501febcb2e7 (patch)
treef7fdb5ca6f5ff3558d90a0c09314559022f46810
parentc5ab71d7a5bc5927b5bc3342a32baabb07f3ba2c (diff)
downloadsyncthing-25ec2b63abb4d43d37833acdc9cda501febcb2e7.tar.gz
syncthing-25ec2b63abb4d43d37833acdc9cda501febcb2e7.zip
cmd/ursrv: Summarize tiny fraction items into Other
-rw-r--r--cmd/ursrv/analytics.go21
-rw-r--r--cmd/ursrv/main.go6
2 files changed, 23 insertions, 4 deletions
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