mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
Truncate list of versions
This commit is contained in:
parent
9c51cf50ad
commit
97a9ca24f3
11
analytics.go
11
analytics.go
@ -23,7 +23,7 @@ func (l analyticList) Len() int {
|
||||
}
|
||||
|
||||
// Returns a list of frequency analytics for a given list of strings.
|
||||
func analyticsFor(ss []string) []analytic {
|
||||
func analyticsFor(ss []string, cutoff int) []analytic {
|
||||
m := make(map[string]int)
|
||||
t := 0
|
||||
for _, s := range ss {
|
||||
@ -37,6 +37,15 @@ func analyticsFor(ss []string) []analytic {
|
||||
}
|
||||
|
||||
sort.Sort(analyticList(l))
|
||||
|
||||
if cutoff > 0 && len(l) > cutoff {
|
||||
c := 0
|
||||
for _, i := range l[cutoff:] {
|
||||
c += i.Count
|
||||
}
|
||||
l = append(l[:cutoff], analytic{"Others", c, 100 * float64(c) / float64(t)})
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
|
6
main.go
6
main.go
@ -363,9 +363,9 @@ func getReport(key string) map[string]interface{} {
|
||||
r["key"] = key
|
||||
r["nodes"] = nodes
|
||||
r["categories"] = categories
|
||||
r["versions"] = analyticsFor(versions)
|
||||
r["platforms"] = analyticsFor(platforms)
|
||||
r["os"] = analyticsFor(oses)
|
||||
r["versions"] = analyticsFor(versions, 10)
|
||||
r["platforms"] = analyticsFor(platforms, 0)
|
||||
r["os"] = analyticsFor(oses, 0)
|
||||
|
||||
reportCache = r
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user