diff pkg/controllers/bottlenecks.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 3bba82bcb6a6
children deea2f15400f
line wrap: on
line diff
--- a/pkg/controllers/bottlenecks.go	Thu May 16 17:22:33 2019 +0200
+++ b/pkg/controllers/bottlenecks.go	Thu May 16 18:41:43 2019 +0200
@@ -73,9 +73,10 @@
 SELECT
   grwl.depth_reference,
   grwl.value
-FROM waterway.gauges_reference_water_levels grwl JOIN 
-     waterway.bottlenecks bns
-	 ON bns.fk_g_fid = grwl.gauge_id
+FROM waterway.gauges_reference_water_levels grwl
+  JOIN waterway.bottlenecks bns
+    ON grwl.location = bns.gauge_location
+      AND grwl.validity = bns.gauge_validity
 WHERE bns.objnam = $1 AND (
   grwl.depth_reference like 'HDC%' OR
   grwl.depth_reference like 'LDC%' OR
@@ -85,9 +86,10 @@
 	selectGaugeLDCSQL = `
 SELECT
   grwl.value
-FROM waterway.gauges_reference_water_levels grwl JOIN
-     waterway.bottlenecks bns
-	 ON bns.fk_g_fid = grwl.gauge_id
+FROM waterway.gauges_reference_water_levels grwl
+  JOIN waterway.bottlenecks bns
+    ON grwl.location = bns.gauge_location
+      AND grwl.validity = bns.gauge_validity
 WHERE bns.objnam = $1 AND grwl.depth_reference like 'LDC%'
 `
 )