Mercurial > gemma
comparison pkg/models/sr.go @ 4055:98e2041c7ebf historization_ng
Adapted sr-import to new historization model.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 24 Jul 2019 18:16:27 +0200 |
parents | 3bdbaf1b282a |
children | 85f19e924a43 |
comparison
equal
deleted
inserted
replaced
4054:033a8e3fec8e | 4055:98e2041c7ebf |
---|---|
39 const ( | 39 const ( |
40 checkDepthReferenceSQL = ` | 40 checkDepthReferenceSQL = ` |
41 SELECT EXISTS(SELECT 1 | 41 SELECT EXISTS(SELECT 1 |
42 FROM waterway.bottlenecks bn | 42 FROM waterway.bottlenecks bn |
43 JOIN waterway.gauges g | 43 JOIN waterway.gauges g |
44 ON bn.gauge_location = g.location AND bn.gauge_validity = g.validity | 44 ON bn.gauge_location = g.location AND $3::timestamptz <@ g.validity |
45 JOIN waterway.gauges_reference_water_levels rl | 45 JOIN waterway.gauges_reference_water_levels rl |
46 ON g.location = rl.location AND g.validity = rl.validity | 46 ON g.location = rl.location AND g.validity = rl.validity |
47 WHERE bn.objnam = $1 | 47 WHERE bn.objnam = $1 |
48 AND rl.depth_reference = $2)` | 48 AND rl.depth_reference = $2)` |
49 | 49 |
83 | 83 |
84 if m.DepthReference != "ZPG" { | 84 if m.DepthReference != "ZPG" { |
85 err = conn.QueryRowContext(ctx, | 85 err = conn.QueryRowContext(ctx, |
86 checkDepthReferenceSQL, | 86 checkDepthReferenceSQL, |
87 m.Bottleneck, | 87 m.Bottleneck, |
88 m.DepthReference).Scan(&b) | 88 m.DepthReference, |
89 m.Date.Time).Scan(&b) | |
89 switch { | 90 switch { |
90 case !b: | 91 case !b: |
91 errs = append(errs, | 92 errs = append(errs, |
92 fmt.Errorf("unknown depth reference '%s'", m.DepthReference)) | 93 fmt.Errorf("unknown depth reference '%s'", m.DepthReference)) |
93 case err != nil: | 94 case err != nil: |