From 418bf5176e6669ef42e0ca45eac80bec5cdf1bed Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 8 Jul 2022 15:36:12 +0200 Subject: [PATCH] console: exclude 0 from minimum value --- console/graph.go | 10 +++++++++- console/graph_test.go | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/console/graph.go b/console/graph.go index b00cbc92..d31c230d 100644 --- a/console/graph.go +++ b/console/graph.go @@ -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) { diff --git a/console/graph_test.go b/console/graph_test.go index 9c5008ed..1df496aa 100644 --- a/console/graph_test.go +++ b/console/graph_test.go @@ -215,9 +215,9 @@ func TestGraphHandler(t *testing.T) { "min": []int{ 2000, 100, - 0, - 0, - 0, + 1200, + 1100, + 100, 100, }, "max": []int{