Mercurial > gemma
changeset 5593:88a41fc07c97
Merged surveysperbottleneckid
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Tue, 19 Apr 2022 13:02:45 +0200 |
parents | 41d7bbc9eac1 (current diff) 613612ce0ff6 (diff) |
children | 2b6c235e33b0 |
files | |
diffstat | 15 files changed, 177 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Bottlenecks.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/Bottlenecks.vue Tue Apr 19 13:02:45 2022 +0200 @@ -7,7 +7,7 @@ /> <UITableHeader :columns="[ - { id: 'properties.name', title: `${nameLabel}`, width: '230px' }, + { id: 'properties.displayName', title: `${nameLabel}`, width: '230px' }, { id: 'properties.responsible_country', title: `${countryLabel}`, @@ -29,7 +29,7 @@ <template v-slot:row="{ item: bottleneck }"> <div class="table-cell truncate text-left" style="width: 230px"> <a href="#" @click="selectBottleneck(bottleneck)">{{ - bottleneck.properties.name + bottleneck.properties.displayName }}</a> </div> <div class="table-cell text-center" style="width: 100px"> @@ -86,7 +86,7 @@ * Author(s): * Markus Kottländer <markus.kottlaender@intevation.de> */ -import { mapState } from "vuex"; +import { mapState, mapGetters } from "vuex"; import { HTTP } from "@/lib/http"; import { displayError } from "@/lib/errors"; import { sortTable } from "@/lib/mixins"; @@ -104,7 +104,7 @@ }, computed: { ...mapState("application", ["searchQuery", "showSearchbarLastState"]), - ...mapState("bottlenecks", ["bottlenecksList"]), + ...mapGetters("bottlenecks", ["bottlenecksForDisplay"]), bottlenecksLabel() { return this.$gettext("Bottlenecks"); }, @@ -128,7 +128,7 @@ }, methods: { filteredBottlenecks() { - return this.bottlenecksList.filter(bn => { + return this.bottlenecksForDisplay.filter(bn => { return bn.properties.name .toLowerCase() .includes(this.searchQuery.toLowerCase()); @@ -138,7 +138,7 @@ this.$store .dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.properties.name + bottleneck.properties.bottleneck_id ) .then(() => { this.$store.commit("bottlenecks/selectedSurvey", survey); @@ -155,7 +155,7 @@ this.$store .dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.properties.name + bottleneck.properties.bottleneck_id ) .then(() => { this.$store.dispatch("map/moveToFeauture", { @@ -175,12 +175,16 @@ this.openBottleneckSurveys = null; } else { this.loading = bottleneck; - HTTP.get("/surveys/" + encodeURIComponent(bottleneck.properties.name), { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" + HTTP.get( + "/surveys?id=" + + encodeURIComponent(bottleneck.properties.bottleneck_id), + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } } - }) + ) .then(response => { this.openBottleneckSurveys = response.data.surveys.sort((a, b) => { return a.date_info < b.date_info ? 1 : -1;
--- a/client/src/components/Pdftool.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/Pdftool.vue Tue Apr 19 13:02:45 2022 +0200 @@ -826,7 +826,7 @@ this.pdf.doc.setTextColor(color); let textOptions = { baseline: "hanging" }; let str1_1 = this.$gettext("Bottleneck") + ": "; - let str1_2 = this.selectedBottleneck; + let str1_2 = this.bottleneckForPrint; let str2_1 = this.$gettext("Survey date") + ": "; let str2_2 = survey.date_info + " (" + SURVEYTYPES[survey["survey_type"]] + ")";
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Tue Apr 19 13:02:45 2022 +0200 @@ -73,7 +73,8 @@ :key="bn.properties.id" :value="bn" > - {{ bn.properties.name }} + {{ bn.properties.displayName }} + <!-- name for display is okay --> </option> </optgroup> </select> @@ -440,8 +441,9 @@ if (this.type !== this.$options.BOTTLENECK) return true; if ( this.selectedEntry && - this.limitingFactorsPerBottleneck[this.selectedEntry.properties.name] == - this.$options.LIMITINGFACTORS.DEPTH + this.limitingFactorsPerBottleneck[ + this.selectedEntry.properties.bottleneck_id + ] == this.$options.LIMITINGFACTORS.DEPTH ) return true; return false; @@ -450,8 +452,9 @@ if (this.type !== this.$options.BOTTLENECK) return true; if ( this.selectedEntry && - this.limitingFactorsPerBottleneck[this.selectedEntry.properties.name] == - this.$options.LIMITINGFACTORS.WIDTH + this.limitingFactorsPerBottleneck[ + this.selectedEntry.properties.bottleneck_id + ] == this.$options.LIMITINGFACTORS.WIDTH ) return true; }, @@ -459,7 +462,7 @@ if (this.type !== this.$options.BOTTLENECK) return; if (this.selectedEntry) return this.limitingFactorsPerBottleneck[ - this.selectedEntry.properties.name + this.selectedEntry.properties.bottleneck_id ]; }, isComplete() { @@ -665,11 +668,11 @@ .setVisible(true); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - this.selectedFairwayAvailabilityFeature.properties.name + this.selectedFairwayAvailabilityFeature.properties.bottleneck_id ); this.$store.commit( "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + this.selectedFairwayAvailabilityFeature.properties.objnam // for printing objnam is okay ); } if (this.type === this.$options.STRETCH) { @@ -839,7 +842,7 @@ }, setSelectedBottleneck() { const bn = this.bottlenecksList.filter( - x => x.properties.name === this.selectedBottleneck + x => x.properties.bottleneck_id === this.selectedBottleneck )[0]; this.$store.commit( "fairwayavailability/setSelectedFairwayAvailability",
--- a/client/src/components/fairway/BottleneckDialogue.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/fairway/BottleneckDialogue.vue Tue Apr 19 13:02:45 2022 +0200 @@ -29,9 +29,10 @@ <option v-for="bn in bottlenecksForCountry" :key="bn.properties.id" - :value="bn.properties.name" + :value="bn.properties.bottleneck_id" > - {{ bn.properties.name }} + {{ bn.properties.displayName }} + <!-- name for display is okay--> </option> </optgroup> </select> @@ -373,7 +374,7 @@ isAllowedToDelete() { const userCountryCode = this.userCountries[this.user]; const bottleneck = this.bottlenecksList.find( - bn => bn.properties.name === this.selectedBottleneck + bn => bn.properties.bottleneck_id === this.selectedBottleneck ); if (!bottleneck) return; if (this.isWaterwayAdmin || this.isSysAdmin) { @@ -421,8 +422,11 @@ get() { return this.$store.state.bottlenecks.selectedBottleneck; }, - set(name) { - this.$store.dispatch("bottlenecks/setSelectedBottleneck", name); + set(bottleneck_id) { + this.$store.dispatch( + "bottlenecks/setSelectedBottleneck", + bottleneck_id + ); } }, selectedWaterLevel: { @@ -517,15 +521,17 @@ .getLayer("BOTTLENECKS") .getSource() .getFeatures() - .find(f => f.get("objnam") === this.selectedBottleneck) + .find(f => f.get("bottleneck_id") === this.selectedBottleneck) : null; } }, watch: { selectedBottleneck() { this.$store.dispatch("fairwayprofile/previousCuts"); - this.cutLabel = - this.selectedBottleneck + " (" + new Date().toISOString() + ")"; + if (this.bottleneck) { + this.cutLabel = + this.bottleneck.get("objnam") + " (" + new Date().toISOString() + ")"; //objnam for Label is okay + } }, selectedSurvey(survey) { this.loadProfile(survey); @@ -726,7 +732,8 @@ JSON.parse(localStorage.getItem("previousCuts")) || []; const newEntry = { label: this.cutLabel, - bottleneckName: this.selectedBottleneck, + bottleneckName: this.bottleneck.get("objnam"), + bottleneckId: this.bottleneck.get("bottleneck_id"), coordinates: [...this.startPoint, ...this.endPoint], timestamp: new Date().getTime(), depth: this.depth, @@ -739,7 +746,6 @@ if (previousCuts.length > 100) previousCuts.shift(); localStorage.setItem("previousCuts", JSON.stringify(previousCuts)); this.$store.dispatch("fairwayprofile/previousCuts"); - this.showLabelInput = false; displayInfo({ title: this.$gettext("Profile saved!"), @@ -811,12 +817,12 @@ }, takeMeThere() { const bottleneck = this.bottlenecksList.find( - bn => bn.properties.name === this.selectedBottleneck + bn => bn.properties.bottleneck_id === this.selectedBottleneck ); if (!bottleneck) return; this.$store.commit( "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + bottleneck.properties.name ); this.$store.dispatch("map/moveToFeauture", { feature: bottleneck,
--- a/client/src/components/fairway/Fairwayprofile.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/fairway/Fairwayprofile.vue Tue Apr 19 13:02:45 2022 +0200 @@ -239,9 +239,9 @@ this.waterlevelValid && this.refWaterlevelValid ? `${this.$options.filters.waterlevel(this.waterlevel)} m` : this.$gettext("No valid value available"); - return `${this.$gettext("Fairwayprofile")}: ${ - this.selectedBottleneck - } (${dates.join( + return `${this.$gettext("Fairwayprofile")}: ${this.bottleneck.get( + "objnam" //for title label objnam is okay + )} (${dates.join( ", " )}) WL: ${waterlevelLabel} ( ${waterlevelMeasurement} )`; }, @@ -266,7 +266,7 @@ .getLayer("BOTTLENECKS") .getSource() .getFeatures() - .find(f => f.get("objnam") === this.selectedBottleneck); + .find(f => f.get("bottleneck_id") === this.selectedBottleneck); }, waterlevel() { return this.selectedWaterLevel === "ref" @@ -286,7 +286,7 @@ fileName() { return this.downloadFilename( this.$gettext("Fairwayprofile"), - this.selectedBottleneck + this.bottleneck.get("objnam") //for filename objnam is okay ); } }, @@ -446,7 +446,10 @@ }, downloadPDF() { let fairwayInfo = - this.selectedBottleneck + " (" + this.selectedSurvey.date_info + ")"; + this.bottleneck.get("objnam") + //for Filename objnam is okay + " (" + + this.selectedSurvey.date_info + + ")"; this.generatePDF({ templateData: this.templateData, diagramTitle: fairwayInfo
--- a/client/src/components/importconfiguration/types/Soundingresults.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/importconfiguration/types/Soundingresults.vue Tue Apr 19 13:02:45 2022 +0200 @@ -22,10 +22,11 @@ > <option v-for="bn in bottlenecksForCountry" - :key="bn.properties.objnam" + :key="bn.properties.bottleneck_id" :value="bn" > - {{ bn.properties.objnam }} + {{ bn.properties.displayName }} + <!-- objnam for label is okay --> </option> </optgroup> </select> @@ -303,7 +304,7 @@ const surveyType = response.data.meta["survey-type"]; this.negateZ = response.data.meta["negate-z"]; this.bottleneck = this.bottlenecks.find( - bn => bn.properties.objnam === bottleneck + bn => bn.properties.bottleneck_id === bottleneck ); this.depthReference = depthReference; this.importDate = new Date(date).toISOString().split("T")[0]; @@ -343,7 +344,7 @@ let formData = new FormData(); formData.append("token", this.token); if (this.bottleneck) - formData.append("bottleneck", this.bottleneck.properties.objnam); + formData.append("bottleneck", this.bottleneck.properties.bottleneck_id); if (this.importDate) formData.append("date", this.importDate.split("T")[0]); if (this.depthReference) @@ -362,7 +363,7 @@ title: this.$gettext("Import"), message: this.$gettext("Starting import for ") + - this.bottleneck.properties.objnam + this.bottleneck.properties.objnam //objnam for display is okay }); this.initialState(); }) @@ -419,8 +420,8 @@ return this.$gettext("Select bottleneck"); }, orderedBottlenecks() { - let groupedBottlenecks = {}, - orderedGroups = {}; + const groupedBottlenecks = {}; + const orderedGroups = {}; // group bottlenecks by cc this.availableBottlenecks.forEach(bn => { @@ -435,8 +436,27 @@ // order groups by cc Object.keys(groupedBottlenecks) .sort() - .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); - + .forEach(cc => { + const names = {}; + const doubleNames = {}; + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (!names[name]) { + names[name] = name; + } else { + doubleNames[name] = name; + } + }); + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (doubleNames[name]) { + bn.properties.displayName = `${name} [${bn.properties.bottleneck_id}]`; + } else { + bn.properties.displayName = name; + } + }); + orderedGroups[cc] = groupedBottlenecks[cc]; + }); return orderedGroups; }, editState() { @@ -464,7 +484,7 @@ encodeURIComponent( JSON.stringify({ "depth-reference": this.depthReference, - bottleneck: this.bottleneck.properties.objnam, + bottleneck: this.bottleneck.properties.bottleneck_id, date: this.importDate, "survey-type": this.beamType, epsg: Number(this.projection),
--- a/client/src/components/importoverview/BottleneckDetail.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/importoverview/BottleneckDetail.vue Tue Apr 19 13:02:45 2022 +0200 @@ -20,6 +20,7 @@ </div> <a @click="moveToBottleneck(index)" href="#"> {{ bottleneck.properties.objnam }} + <!-- objnam for Text is okay--> </a> </div>
--- a/client/src/components/importoverview/SoundingResultDetail.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/importoverview/SoundingResultDetail.vue Tue Apr 19 13:02:45 2022 +0200 @@ -31,6 +31,8 @@ * Thomas Junk <thomas.junk@intevation.de> */ import { mapState } from "vuex"; +import { HTTP } from "@/lib/http"; +import { displayError } from "@/lib/errors"; export default { name: "soundingresultdetails",
--- a/client/src/components/map/MapPopup.vue Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/components/map/MapPopup.vue Tue Apr 19 13:02:45 2022 +0200 @@ -6,11 +6,11 @@ class="d-flex flex-nowrap justify-content-between align-items-center mt-1" v-if="bottlenecks.length" v-for="bottleneck in bottlenecks" - :key="bottleneck.get('objnam')" + :key="bottleneck.get('bottleneck_id')" > <div class="mr-2"> <font-awesome-icon icon="ship" class="mr-1" fixed-width /> - {{ bottleneck.get("objnam") }} + {{ bottleneck.get("objnam") }} [{{ bottleneck.get("bottleneck_id") }}] </div> <div> <button @@ -180,7 +180,7 @@ this.$store.commit("application/showProfiles", true); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.get("objnam") + bottleneck.get("bottleneck_id") ); this.$store.dispatch("map/moveToBoundingBox", { boundingBox: bottleneck @@ -190,10 +190,10 @@ .getExtent(), zoom: 16 }); - this.$store.commit( - "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + const bn = this.bottlenecks.find( + b => b.get("bottleneck_id") == this.selectedBottleneck ); + this.$store.commit("bottlenecks/setBottleneckForPrint", bn.name); //name is okay. this.close(); }, openGauges(gauge) { @@ -209,7 +209,7 @@ this.$store.commit("fairwayavailability/type", TYPES.BOTTLENECK); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.get("objnam") + bottleneck.get("bottleneck_id") ); this.$store.dispatch("map/moveToBoundingBox", { boundingBox: bottleneck @@ -219,10 +219,10 @@ .getExtent(), zoom: 16 }); - this.$store.commit( - "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + const bn = this.bottlenecks.find( + b => b.bottleneck_id == this.selectedBottleneck ); + this.$store.commit("bottlenecks/setBottleneckForPrint", bn.name); //name is okay. this.openFairwayAvailability(); }, openFairwayAvailabilityForStretch(stretch) {
--- a/client/src/store/bottlenecks.js Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/store/bottlenecks.js Tue Apr 19 13:02:45 2022 +0200 @@ -14,8 +14,8 @@ */ import { HTTP } from "@/lib/http"; import { WFS } from "ol/format"; +import { compareAsc } from "date-fns"; import { displayError } from "@/lib/errors"; -import { compareAsc } from "date-fns"; // initial state const init = () => { return { @@ -38,14 +38,35 @@ limitingFactorsPerBottleneck: state => { if (state.bottlenecks.length === 0) return {}; return state.bottlenecks.reduce((o, n) => { - o[n.properties.objnam] = n.properties.limiting; + o[n.properties.bottleneck_id] = n.properties.limiting; return o; }, {}); }, + bottlenecksForDisplay: state => { + const names = {}; + const doubleNames = {}; + const bottlenecks = state.bottlenecksList.map(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (!names[name]) { + names[name] = name; + } else { + doubleNames[name] = name; + } + return bn; + }); + return bottlenecks.map(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (doubleNames[name]) { + bn.properties.displayName = `${name} [${bn.properties.bottleneck_id}]`; + } else { + bn.properties.displayName = name; + } + return bn; + }); + }, orderedBottlenecks: state => { - let groupedBottlenecks = {}, - orderedGroups = {}; - + const groupedBottlenecks = {}; + const orderedGroups = {}; // group bottlenecks by cc state.bottlenecksList.forEach(bn => { let cc = bn.properties.responsible_country; @@ -59,7 +80,27 @@ // order groups by cc Object.keys(groupedBottlenecks) .sort() - .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); + .forEach(cc => { + const names = {}; + const doubleNames = {}; + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (!names[name]) { + names[name] = name; + } else { + doubleNames[name] = name; + } + }); + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (doubleNames[name]) { + bn.properties.displayName = `${name} [${bn.properties.bottleneck_id}]`; + } else { + bn.properties.displayName = name; + } + }); + orderedGroups[cc] = groupedBottlenecks[cc]; + }); return orderedGroups; } @@ -77,8 +118,8 @@ setBottlenecksList: (state, bottlenecksList) => { state.bottlenecksList = bottlenecksList; }, - setSelectedBottleneck: (state, name) => { - state.selectedBottleneck = name; + setSelectedBottleneck: (state, value) => { + state.selectedBottleneck = value; }, setSurveys(state, surveys) { state.surveys = surveys; @@ -98,9 +139,9 @@ } }, actions: { - setSelectedBottleneck({ state, commit, rootState }, name) { + setSelectedBottleneck({ state, commit, rootState }, id) { return new Promise((resolve, reject) => { - if (name !== state.selectedBottleneck) { + if (id !== state.selectedBottleneck) { commit("selectedSurvey", null); commit("fairwayprofile/additionalSurvey", null, { root: true }); commit("fairwayprofile/clearCurrentProfile", null, { root: true }); @@ -111,10 +152,10 @@ .clear(); }); } - commit("setSelectedBottleneck", name); - if (name) { + commit("setSelectedBottleneck", id); + if (id) { commit("surveysLoading", true); - HTTP.get("/surveys/" + encodeURIComponent(name), { + HTTP.get("/surveys?id=" + encodeURIComponent(id), { headers: { "X-Gemma-Auth": localStorage.getItem("token"), "Content-type": "text/xml; charset=UTF-8" @@ -184,6 +225,7 @@ featureTypes: ["bottlenecks_geoserver"], outputFormat: "application/json", propertyNames: [ + "bottleneck_id", "objnam", "responsible_country", "limiting",
--- a/client/src/store/fairwayprofile.js Thu Mar 10 17:25:44 2022 +0100 +++ b/client/src/store/fairwayprofile.js Tue Apr 19 13:02:45 2022 +0200 @@ -1,3 +1,5 @@ +import { HTTP } from "@/lib/http"; +import LineString from "ol/geom/LineString"; /* This is Free Software under GNU Affero General Public License v >= 3.0 * without warranty, see README.md and license for details. * @@ -13,13 +15,11 @@ * Markus Kottländer <markuks.kottlaender@intevation.de> */ import Vue from "vue"; -import { HTTP } from "@/lib/http"; -import { prepareProfile } from "@/lib/geo"; -import LineString from "ol/geom/LineString"; +import { displayError } from "@/lib/errors"; +import { featureToFairwayCoordinates } from "@/lib/geo"; import { generateFeatureRequest } from "@/lib/geo"; import { getLength } from "ol/sphere"; -import { displayError } from "@/lib/errors"; -import { featureToFairwayCoordinates } from "@/lib/geo"; +import { prepareProfile } from "@/lib/geo"; // initial state const init = () => { @@ -316,7 +316,7 @@ previousCuts .filter(cut => { return ( - cut.bottleneckName === rootState.bottlenecks.selectedBottleneck + cut.bottleneckId === rootState.bottlenecks.selectedBottleneck ); }) .sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1))
--- a/pkg/controllers/routes.go Thu Mar 10 17:25:44 2022 +0100 +++ b/pkg/controllers/routes.go Tue Apr 19 13:02:45 2022 +0200 @@ -177,9 +177,13 @@ })).Methods(http.MethodGet) // Survey selection - api.Handle("/surveys/{bottleneck:.+}", any(&mw.JSONHandler{ + api.Handle("/surveys", any(&mw.JSONHandler{ Handle: listSurveys, - })).Methods(http.MethodGet) + })).Methods(http.MethodGet).Queries("id", "{id}") + + api.Handle("/surveys", any(&mw.JSONHandler{ + Handle: listSurveys, + })).Methods(http.MethodGet).Queries("name", "{name}", "date", "{date}") // difference calculation api.Handle("/diff", any(&mw.JSONHandler{
--- a/pkg/controllers/surveys.go Thu Mar 10 17:25:44 2022 +0100 +++ b/pkg/controllers/surveys.go Tue Apr 19 13:02:45 2022 +0200 @@ -27,7 +27,7 @@ ) const ( - listSurveysSQL = ` + listSurveysByIdSQL = ` SELECT DISTINCT s.bottleneck_id, s.date_info::text, @@ -42,16 +42,16 @@ LEFT JOIN waterway.gauges_reference_water_levels AS r ON s.depth_reference = r.depth_reference AND g.location = r.location AND g.validity = r.validity -WHERE b.objnam = $1` +WHERE b.bottleneck_id = $1` ) func listSurveys(req *http.Request) (jr mw.JSONResult, err error) { - bottleneckName := mux.Vars(req)["bottleneck"] + bottleneckId := mux.Vars(req)["id"] var rows *sql.Rows - rows, err = mw.JSONConn(req).QueryContext(req.Context(), listSurveysSQL, bottleneckName) + rows, err = mw.JSONConn(req).QueryContext(req.Context(), listSurveysByIdSQL, bottleneckId) if err != nil { return }
--- a/pkg/imports/sr.go Thu Mar 10 17:25:44 2022 +0100 +++ b/pkg/imports/sr.go Tue Apr 19 13:02:45 2022 +0200 @@ -145,8 +145,8 @@ area, surtyp, zpg_exception -) SELECT - bottleneck_id, +) VALUES ( + $1, $2::date, $3, (SELECT @@ -157,8 +157,7 @@ END), $7, $8 -FROM waterway.bottlenecks -WHERE objnam = $1 AND validity @> CAST($2 AS timestamptz) +) RETURNING id, ST_X(ST_Centroid(area::geometry)), @@ -226,7 +225,7 @@ JOIN waterway.bottlenecks bns ON grwl.location = bns.gauge_location AND grwl.validity @> CAST($2 AS timestamptz) -WHERE bns.objnam = $1 +WHERE bns.bottleneck_id = $1 AND bns.validity @> CAST($2 AS timestamptz) AND grwl.depth_reference like 'LDC%' `
--- a/pkg/models/sr.go Thu Mar 10 17:25:44 2022 +0100 +++ b/pkg/models/sr.go Tue Apr 19 13:02:45 2022 +0200 @@ -67,16 +67,16 @@ ON bn.gauge_location = g.location AND $3::timestamptz <@ g.validity JOIN waterway.gauges_reference_water_levels rl ON g.location = rl.location AND g.validity = rl.validity - WHERE bn.objnam = $1 + WHERE bn.bottleneck_id = $1 AND rl.depth_reference = $2)` checkBottleneckSQL = ` -SELECT true FROM waterway.bottlenecks WHERE objnam = $1` +SELECT true FROM waterway.bottlenecks WHERE bottleneck_id = $1` checkBottleneckDateUniqueSQL = ` SELECT true FROM waterway.sounding_results sr JOIN waterway.bottlenecks bn ON sr.bottleneck_id = bn.bottleneck_id -WHERE bn.objnam = $1 AND sr.date_info = $2` +WHERE bn.bottleneck_id = $1 AND sr.date_info = $2` ) func (m *SoundingResultMeta) Decode(r io.Reader) error {