# HG changeset patch # User Sascha L. Teichmann # Date 1557330788 -7200 # Node ID 3bba82bcb6a6a3bcdf1314b6fbaaac67fce0f8c2 # Parent ba7bc3740fb3d0ed2e019bd6c756f4e2069d3db0 Second fix to waterlevel classification. Set the bounds of the intervals correctly. diff -r ba7bc3740fb3 -r 3bba82bcb6a6 pkg/controllers/bottlenecks.go --- a/pkg/controllers/bottlenecks.go Wed May 08 17:43:18 2019 +0200 +++ b/pkg/controllers/bottlenecks.go Wed May 08 17:53:08 2019 +0200 @@ -155,6 +155,8 @@ return common.InterpolateValueByTime(p1.when, access(p1), p2.when, access(p2)) } + // var total time.Duration + pairs: for i := 0; i < len(measurements)-1; i++ { p1 := &measurements[i] @@ -182,7 +184,7 @@ f, _ := v(from) t, _ := v(to) classify(common.InterpolateTimeByValue(from, f, to, t)) - start, end = from, to + start, end = p1.when, p2.when case p1.when.After(from): // from is inside segment @@ -219,6 +221,8 @@ continue pairs } + // total += end.Sub(start) + for i := len(cvs) - 1; i >= 0; i-- { switch cvs[i].kind { case common.ValueAbove: @@ -241,6 +245,9 @@ result[0] += end.Sub(start) } + // log.Printf("total all: %f\n", to.Sub(from).Hours()) + // log.Printf("total: %f\n", total.Hours()) + return result } @@ -676,10 +683,10 @@ ) record[0] = label - record[1] = fmt.Sprintf("%.3f", ldc[1].Hours()/24) + record[1] = fmt.Sprintf("%.3f", ldc[1].Hours()) for i, d := range ranges { - record[2+i] = fmt.Sprintf("%.3f", d.Hours()/24) + record[2+i] = fmt.Sprintf("%.3f", d.Hours()) } if err := out.Write(record); err != nil {