changeset 4813:0644c2b3af54

Check for mandatory measurement value in GM import.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 29 Oct 2019 17:42:51 +0100
parents 8ab1e60b7f31
children ad2ad7bae4a6
files pkg/imports/gm.go
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/gm.go	Tue Oct 29 17:30:03 2019 +0100
+++ b/pkg/imports/gm.go	Tue Oct 29 17:42:51 2019 +0100
@@ -390,6 +390,13 @@
 				} else {
 					unit = string(*measure.Unit)
 				}
+
+				if measure.Value == nil {
+					feedback.Warn("Missing mandatory value at %s. Ignored (bad service)",
+						measure.Measuredate.Format(time.RFC3339))
+					continue
+				}
+
 				convert, err := rescale(unit)
 				if err != nil {
 					return nil, err
@@ -399,7 +406,7 @@
 				convert(measure.Value_max)
 
 				// -99999 is used by some gauges to signal an error
-				if measure.Value != nil && *measure.Value == -99999 {
+				if *measure.Value == -99999 {
 					badValue++
 					continue
 				}
@@ -453,11 +460,6 @@
 						newP++
 					}
 				} else {
-					if measure.Value == nil {
-						feedback.Info("Missing value at %s. Ignored",
-							measure.Measuredate.Format(time.RFC3339))
-						continue
-					}
 					err = insertGMStmt.QueryRowContext(
 						ctx,
 						currIsrs.CountryCode,