console: exclude 0 from minimum value

This commit is contained in:
Vincent Bernat
2022-07-08 15:36:12 +02:00
parent 70a4029eb5
commit 418bf5176e
2 changed files with 12 additions and 4 deletions

View File

@@ -231,8 +231,16 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) {
s := make([]int, len(rowValues[r]))
copy(s, rowValues[r])
sort.Ints(s)
output.Min[idx] = s[0]
// Min (but not 0)
for i := 0; i < len(s); i++ {
output.Min[idx] = s[i]
if s[i] > 0 {
break
}
}
// Max
output.Max[idx] = s[len(s)-1]
// 95th percentile
index := 0.95 * float64(len(s))
j := int(index)
if index == float64(j) {

View File

@@ -215,9 +215,9 @@ func TestGraphHandler(t *testing.T) {
"min": []int{
2000,
100,
0,
0,
0,
1200,
1100,
100,
100,
},
"max": []int{