Mercurial > gemma
diff pkg/controllers/surveys.go @ 2317:8a8680e70d2e
Cleanup schema for reference water levels
Remove duplicate lookup table and leave an out-commented foreign key
constraint to make clear what should be referenced.
The removed comment in surveys.go mostly became obsolete and was
otherwise trying to explain SQL basics.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 18 Feb 2019 18:45:12 +0100 |
parents | 8132434f4093 |
children | ec6163c6687d |
line wrap: on
line diff
--- a/pkg/controllers/surveys.go Mon Feb 18 16:41:09 2019 +0100 +++ b/pkg/controllers/surveys.go Mon Feb 18 18:45:12 2019 +0100 @@ -24,15 +24,6 @@ ) const ( - // Use the same logic as in schema/gemma.sql to find out - // which is the reference gauge and which from its values is meant. - // The LEFT for the JOIN is necessary because we still want to list - // the surveys even if the corresponding value cannot be found because the - // depth_reference and reference_water_level strings do not match. - // - // As this information could be vary from survey entry to survey, - // in theory even for the same bottleneck - // it seems to be the right place to return it from the /surveys endpoint. listSurveysSQL = ` SELECT s.bottleneck_id, @@ -49,7 +40,7 @@ ON bg.id = s.bottleneck_id ) LEFT JOIN waterway.gauges_reference_water_levels AS r -ON s.depth_reference = r.reference_water_level AND bg.location = r.gauge_id +ON s.depth_reference = r.depth_reference AND bg.location = r.gauge_id WHERE bg.objnam=$1` )