changeset 5244:8f9cd1df5028 new-fwa

Fixed a copy-by-value problem.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 12 May 2020 19:11:02 +0200
parents 0ab809236eb5
children 9dd1ae697f93
files pkg/controllers/fwa.go
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/fwa.go	Tue May 12 17:27:43 2020 +0200
+++ b/pkg/controllers/fwa.go	Tue May 12 19:11:02 2020 +0200
@@ -297,7 +297,7 @@
 	}
 
 	for i := range record[1:] {
-		record[i+1] = "0.0"
+		record[i+1] = "0"
 	}
 
 	// For every day on every bottleneck we need to find out if this day is valid.
@@ -314,7 +314,7 @@
 	var (
 		totalDays, overLDCDays int
 		missingLDCs            = make([]int, len(validities))
-		counters               = make([]int, len(validities))
+		counters               = make([]int, len(breaks)+1)
 	)
 
 	var current, next time.Time
@@ -350,6 +350,8 @@
 		overLDC := true
 		highest := -1
 
+		var hasValid bool
+
 		// check all bottlenecks
 		for i, validity := range validities {
 
@@ -366,6 +368,8 @@
 				continue
 			}
 
+			hasValid = true
+
 			if overLDC { // If its already not shipable we need no further tests.
 				result := bottlenecks[i].measurements.classify(
 					current, next,
@@ -387,11 +391,13 @@
 			}
 		}
 
-		if overLDC {
-			overLDCDays++
-		}
-		if highest > -1 {
-			counters[highest]++
+		if hasValid {
+			if overLDC {
+				overLDCDays++
+			}
+			if highest > -1 {
+				counters[highest]++
+			}
 		}
 		totalDays++
 
@@ -721,7 +727,8 @@
 		}
 		l.toUTC()
 		for i := range bn.validities {
-			vs := bn.validities[i]
+			vs := &bn.validities[i]
+
 			if vs.intersects(l.lower, l.upper) {
 				vs.ldcs = append(vs.ldcs, &l)
 			}