diff pkg/imports/bn.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 bfde4f8dd323
children 6592396f5061
line wrap: on
line diff
--- a/pkg/imports/bn.go	Thu May 16 17:22:33 2019 +0200
+++ b/pkg/imports/bn.go	Thu May 16 18:41:43 2019 +0200
@@ -47,7 +47,8 @@
 	insertBottleneckSQL = `
 INSERT INTO waterway.bottlenecks (
   bottleneck_id,
-  fk_g_fid,
+  gauge_location,
+  gauge_validity,
   objnam,
   nobjnm,
   stretch,
@@ -59,9 +60,11 @@
   limiting,
   date_info,
   source_organization
-) VALUES(
+) VALUES (
   $1,
   isrs_fromText($2),
+  (SELECT validity FROM waterway.gauges
+     WHERE location = isrs_fromText($2) AND NOT erased),
   $3,
   $4,
   isrsrange(least(isrs_fromText($5), isrs_fromText($6)),