Mercurial > gemma
diff 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 |
line wrap: on
line diff
--- a/pkg/controllers/surveys.go Thu May 16 17:22:33 2019 +0200 +++ b/pkg/controllers/surveys.go Thu May 16 18:41:43 2019 +0200 @@ -29,19 +29,15 @@ s.bottleneck_id, s.date_info::text, s.depth_reference, - bg.objname AS gauge_objname, + g.objname AS gauge_objname, r.value AS waterlevel_value -FROM - ( - ( SELECT * FROM waterway.bottlenecks AS b, waterway.gauges AS g - WHERE b.fk_g_fid = g.location - ) AS bg - JOIN waterway.sounding_results AS s - ON bg.id = s.bottleneck_id - ) -LEFT JOIN waterway.gauges_reference_water_levels AS r -ON s.depth_reference = r.depth_reference AND bg.location = r.gauge_id -WHERE bg.objnam=$1` +FROM waterway.bottlenecks AS b + JOIN waterway.gauges AS g + ON b.gauge_location = g.location AND b.gauge_validity = g.validity + JOIN waterway.sounding_results AS s ON b.id = s.bottleneck_id + LEFT JOIN waterway.gauges_reference_water_levels AS r + USING (depth_reference, location, validity) +WHERE b.objnam = $1` ) func listSurveys(