comparison pkg/controllers/surveys.go @ 5405:5e7fca6ef935 marking-single-beam

When listing surveys tell survey type as well.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 06 Jul 2021 14:18:54 +0200
parents e68220372832
children 6d73836bc2fb
comparison
equal deleted inserted replaced
5404:47b12e8308bf 5405:5e7fca6ef935
31 SELECT DISTINCT 31 SELECT DISTINCT
32 s.bottleneck_id, 32 s.bottleneck_id,
33 s.date_info::text, 33 s.date_info::text,
34 s.depth_reference, 34 s.depth_reference,
35 COALESCE(g.objname, 'ERROR: MISSING GAUGE') AS gauge_objname, 35 COALESCE(g.objname, 'ERROR: MISSING GAUGE') AS gauge_objname,
36 r.value AS waterlevel_value 36 r.value AS waterlevel_value,
37 COALESCE(s.surtype, 'ERROR: MISSING SURVEY TYPE) AS surtype
37 FROM waterway.bottlenecks AS b 38 FROM waterway.bottlenecks AS b
38 JOIN waterway.sounding_results AS s ON b.bottleneck_id = s.bottleneck_id 39 JOIN waterway.sounding_results AS s ON b.bottleneck_id = s.bottleneck_id
39 LEFT JOIN waterway.gauges AS g 40 LEFT JOIN waterway.gauges AS g
40 ON b.gauge_location = g.location AND s.date_info::timestamptz <@ g.validity 41 ON b.gauge_location = g.location AND s.date_info::timestamptz <@ g.validity
41 LEFT JOIN waterway.gauges_reference_water_levels AS r 42 LEFT JOIN waterway.gauges_reference_water_levels AS r
61 // as we do not use the values here, we could simply the code here 62 // as we do not use the values here, we could simply the code here
62 // to work without an explicit mdels/surverys.go 63 // to work without an explicit mdels/surverys.go
63 // (like done in controllers/search.go) 64 // (like done in controllers/search.go)
64 for rows.Next() { 65 for rows.Next() {
65 var survey models.Survey 66 var survey models.Survey
67 var surType string
66 var level sql.NullInt64 68 var level sql.NullInt64
67 if err = rows.Scan( 69 if err = rows.Scan(
68 &survey.BottleneckID, 70 &survey.BottleneckID,
69 &survey.DateInfo, 71 &survey.DateInfo,
70 &survey.DepthReference, 72 &survey.DepthReference,
71 &survey.ReferenceGauge, 73 &survey.ReferenceGauge,
72 &level, 74 &level,
75 &surType,
73 ); err != nil { 76 ); err != nil {
74 return 77 return
75 } 78 }
76 if level.Valid { 79 if level.Valid {
77 survey.WaterLevelValue = &level.Int64 80 survey.WaterLevelValue = &level.Int64
78 } 81 }
82 survey.SurveyType = models.SurveyType(surType)
79 surveys = append(surveys, &survey) 83 surveys = append(surveys, &survey)
80 } 84 }
81 85
82 if err = rows.Err(); err != nil { 86 if err = rows.Err(); err != nil {
83 return 87 return