# HG changeset patch # User Sascha L. Teichmann # Date 1545308394 -3600 # Node ID 334d13e6334216cf7f842f2587c6aab918a4ae1b # Parent c0a2e1cd2284df962dc53bebf526b616c7aedd39 Cosmetics. diff -r c0a2e1cd2284 -r 334d13e63342 pkg/imports/gm.go --- a/pkg/imports/gm.go Thu Dec 20 12:50:37 2018 +0100 +++ b/pkg/imports/gm.go Thu Dec 20 13:19:54 2018 +0100 @@ -194,9 +194,9 @@ } if resp.Result_message == nil { - err := errors.New("No gauge measurements found") + err := errors.New("no gauge measurements found") for i, e := range resp.Result_error { - feedback.Error("%d: %v", i, string(*e)) + feedback.Error("%d: %v", i, e) } return nil, err } @@ -221,11 +221,12 @@ feedback.Info("Found %d gauges with measurements", len(msg.Wrm)) for _, wrm := range msg.Wrm { currIsrs, err := models.IsrsFromString(string(*wrm.Geo_object.Id)) + if err != nil { + feedback.Warn("Invalid ISRS code %v", err) + continue + } for _, measure := range wrm.Measure { - isWaterlevel := false - if *measure.Measure_code == nts.Measure_code_enumWAL { - isWaterlevel = true - } + isWaterlevel := *measure.Measure_code == nts.Measure_code_enumWAL err = insertStmt.QueryRowContext( ctx, currIsrs.CountryCode, @@ -248,8 +249,9 @@ if err != nil { return nil, err } - feedback.Info("Inserted '%s'", currIsrs) } + feedback.Info("Inserted %d measurements for %s", + len(wrm.Measure), currIsrs) gids = append(gids, currIsrs.String()) } } diff -r c0a2e1cd2284 -r 334d13e63342 pkg/models/gauge.go --- a/pkg/models/gauge.go Thu Dec 20 12:50:37 2018 +0100 +++ b/pkg/models/gauge.go Thu Dec 20 13:19:54 2018 +0100 @@ -14,6 +14,7 @@ package models import ( + "errors" "fmt" "strconv" "time" @@ -43,7 +44,7 @@ // IsrsFromString converts string representation of isrs code to type Isrs func IsrsFromString(isrsCode string) (*Isrs, error) { if len(isrsCode) < 20 { - return nil, fmt.Errorf("to short") + return nil, errors.New("ISRS code too short") } hm, err := strconv.Atoi(isrsCode[15:20]) if err != nil { @@ -59,7 +60,7 @@ return &isrs, nil } -// ToString creates a isrs code string from Isrs +// String creates a isrs code string from Isrs func (isrs *Isrs) String() string { return fmt.Sprintf("%s%s%s%s%05d", isrs.CountryCode,