diff pkg/controllers/stretches.go @ 4343:63c25eb9c07c

FA: be optimistic about missing data. According to clarification, missing data has to be interpreted as the best case, this is, because the services do not provide data for bottlenecks, which are not considered a limitating factor on the water way at a given time.
author Sascha Wilde <wilde@intevation.de>
date Fri, 06 Sep 2019 17:22:42 +0200
parents 0f467a839fe2
children 97312d7954ba
line wrap: on
line diff
--- a/pkg/controllers/stretches.go	Fri Sep 06 16:17:36 2019 +0200
+++ b/pkg/controllers/stretches.go	Fri Sep 06 17:22:42 2019 +0200
@@ -279,7 +279,13 @@
 
 				var ldc, breaks []time.Duration
 
+				now := time.Now()
 				for _, bn := range loaded {
+					// Don't interpolate for the future
+					if now.Sub(res.to) < 0 {
+						res.to = now
+					}
+
 					l := bn.measurements.classify(
 						res.from, res.to,
 						bn.ldc,
@@ -539,7 +545,13 @@
 			for res := range jobCh {
 				var ldc, breaks []time.Duration
 
+				now := time.Now()
 				for _, bn := range loaded {
+					// Don't interpolate for the future
+					if now.Sub(res.to) < 0 {
+						res.to = now
+					}
+
 					l := bn.measurements.classify(
 						res.from, res.to,
 						bn.ldc,