Mercurial > gemma
changeset 4515:7465b6244d5e
FA import: Code clean-up for handling default LOS.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 04 Oct 2019 17:37:51 +0200 |
parents | 9f2d690b7076 |
children | 665c4d3fb9a4 9c9786f9466f |
files | pkg/imports/fa.go |
diffstat | 1 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/fa.go Fri Oct 04 17:12:26 2019 +0200 +++ b/pkg/imports/fa.go Fri Oct 04 17:37:51 2019 +0200 @@ -292,6 +292,14 @@ return &summary, nil } +// defaultLOS defaults to LOS3 when no expicit LOS is given. +func defaultLOS(los *ifaf.LosEnum) ifaf.LosEnum { + if los == nil { + return ifaf.LosEnumLOS3 + } + return *los +} + func doForFAs( ctx context.Context, bnIds bottlenecks, @@ -300,8 +308,6 @@ feedback Feedback, ) ([]string, error) { - default_los := ifaf.LosEnumLOS3 - insertFAStmt, err := tx.PrepareContext(ctx, insertFASQL) if err != nil { return nil, err @@ -373,10 +379,6 @@ if faRes.Effective_fairway_availability != nil { efaCount := 0 for _, efa := range faRes.Effective_fairway_availability.EffectiveFairwayAvailability { - los := &default_los - if efa.Level_of_Service != nil { - los = efa.Level_of_Service - } fgt := efa.Forecast_generation_time if efa.Forecast_generation_time.Status == pgtype.Undefined { fgt = pgtype.Timestamp{ @@ -387,7 +389,7 @@ ctx, faID, efa.Measure_date, - string(*los), + string(defaultLOS(efa.Level_of_Service)), efa.Available_depth_value, efa.Available_width_value, efa.Water_level_value, @@ -412,14 +414,10 @@ if faRes.Reference_values != nil { rvCount := 0 for _, fav := range faRes.Reference_values.ReferenceValue { - los := &default_los - if fav.Level_of_Service != nil { - los = fav.Level_of_Service - } res, err := insertFAVStmt.ExecContext( ctx, faID, - los, + string(defaultLOS(fav.Level_of_Service)), fav.Fairway_depth, fav.Fairway_width, fav.Fairway_radius,