# HG changeset patch # User Bernhard Reiter # Date 1549464295 -3600 # Node ID 8f6345ad5f136f7bbbbade9df8d4fd96c306b40b # Parent bc310a0b5bae65ffeef7344aefb5c324fc0f6acb Extend /surveys/ endpoint to include reference gauge * Add a subselection to the sql query in models/surveys.go which similiar to the `bottleneck_geoserver` view assumes that the reference gauge is the same for each survey result. * Maintain rights infos. diff -r bc310a0b5bae -r 8f6345ad5f13 pkg/controllers/surveys.go --- a/pkg/controllers/surveys.go Wed Feb 06 15:35:30 2019 +0100 +++ b/pkg/controllers/surveys.go Wed Feb 06 15:44:55 2019 +0100 @@ -4,13 +4,14 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // -// Copyright (C) 2018 by via donau +// Copyright (C) 2018, 2019 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha Wilde // * Sascha L. Teichmann +// * Bernhard Reiter package controllers @@ -26,10 +27,15 @@ listSurveysSQL = ` SELECT s.bottleneck_id, - s.date_info::text -FROM waterway.bottlenecks b JOIN waterway.sounding_results s -ON b.id = s.bottleneck_id -WHERE b.objnam=$1` + s.date_info::text, + bg.objname AS gauge_objname +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 +WHERE bg.objnam=$1` ) func listSurveys( @@ -55,6 +61,7 @@ if err = rows.Scan( &survey.BottleneckID, &survey.DateInfo, + &survey.ReferenceGauge, ); err != nil { return } diff -r bc310a0b5bae -r 8f6345ad5f13 pkg/models/surveys.go --- a/pkg/models/surveys.go Wed Feb 06 15:35:30 2019 +0100 +++ b/pkg/models/surveys.go Wed Feb 06 15:44:55 2019 +0100 @@ -4,7 +4,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // -// Copyright (C) 2018 by via donau +// Copyright (C) 2018, 2019 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // @@ -15,7 +15,8 @@ type ( Survey struct { - BottleneckID string `json:"bottleneck_id"` - DateInfo string `json:"date_info"` + BottleneckID string `json:"bottleneck_id"` + DateInfo string `json:"date_info"` + ReferenceGauge string `json:"gauge_objname"` } )