comparison pkg/controllers/surveys.go @ 3302:ec6163c6687d

'Historicise' gauges on import Gauge data sets will be updated or a new version will be inserted depending on temporal validity and a timestamp marking the last update in the RIS-Index of a data set. The trigger on date_info is removed because the value is actually an attribut coming from the RIS-Index. Gauge measurements and predictions are associated to the version with matching temporal validity. Bottlenecks are always associated to the actual version of the gauge, although this might change as soon as bottlenecks are 'historicised', too.
author Tom Gottfried <tom@intevation.de>
date Thu, 16 May 2019 18:41:43 +0200
parents 8a8680e70d2e
children 02951a62e8c6
comparison
equal deleted inserted replaced
3301:6514b943654e 3302:ec6163c6687d
27 listSurveysSQL = ` 27 listSurveysSQL = `
28 SELECT 28 SELECT
29 s.bottleneck_id, 29 s.bottleneck_id,
30 s.date_info::text, 30 s.date_info::text,
31 s.depth_reference, 31 s.depth_reference,
32 bg.objname AS gauge_objname, 32 g.objname AS gauge_objname,
33 r.value AS waterlevel_value 33 r.value AS waterlevel_value
34 FROM 34 FROM waterway.bottlenecks AS b
35 ( 35 JOIN waterway.gauges AS g
36 ( SELECT * FROM waterway.bottlenecks AS b, waterway.gauges AS g 36 ON b.gauge_location = g.location AND b.gauge_validity = g.validity
37 WHERE b.fk_g_fid = g.location 37 JOIN waterway.sounding_results AS s ON b.id = s.bottleneck_id
38 ) AS bg 38 LEFT JOIN waterway.gauges_reference_water_levels AS r
39 JOIN waterway.sounding_results AS s 39 USING (depth_reference, location, validity)
40 ON bg.id = s.bottleneck_id 40 WHERE b.objnam = $1`
41 )
42 LEFT JOIN waterway.gauges_reference_water_levels AS r
43 ON s.depth_reference = r.depth_reference AND bg.location = r.gauge_id
44 WHERE bg.objnam=$1`
45 ) 41 )
46 42
47 func listSurveys( 43 func listSurveys(
48 _ interface{}, 44 _ interface{},
49 req *http.Request, 45 req *http.Request,