Browse Source

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

Jakob Borg 9 years ago
parent
commit
dd175c5431
1 changed files with 14 additions and 0 deletions
  1. 14 0
      cmd/ursrv/main.go

+ 14 - 0
cmd/ursrv/main.go

@@ -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)