In the versions graph, filter out versions with <50 devices

This commit is contained in:
Jakob Borg 2016-07-08 10:00:07 +02:00
parent 6e960f1972
commit dd175c5431

View File

@ -773,12 +773,14 @@ func transformVersion(v string) string {
type summary struct {
versions map[string]int // version string to count index
max map[string]int // version string to max users per day
rows map[string][]int // date to list of counts
}
func newSummary() summary {
return summary{
versions: make(map[string]int),
max: make(map[string]int),
rows: make(map[string][]int),
}
}
@ -790,6 +792,10 @@ func (s *summary) setCount(date, version string, count int) {
s.versions[version] = idx
}
if s.max[version] < count {
s.max[version] = count
}
row := s.rows[date]
if len(row) <= idx {
old := row
@ -808,6 +814,14 @@ func (s *summary) MarshalJSON() ([]byte, error) {
}
sort.Strings(versions)
var filtered []string
for _, v := range versions {
if s.max[v] > 50 {
filtered = append(filtered, v)
}
}
versions = filtered
headerRow := []interface{}{"Day"}
for _, v := range versions {
headerRow = append(headerRow, v)