changeset 5248:8c44b518141a new-fwa

Don't intersect with validities when fetching bottleneck_ids for sections and stretches.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 12 May 2020 22:35:33 +0200
parents d89f5d75223e
children d855426a6e5d
files pkg/controllers/fwa.go
diffstat 1 files changed, 6 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/fwa.go	Tue May 12 22:24:16 2020 +0200
+++ b/pkg/controllers/fwa.go	Tue May 12 22:35:33 2020 +0200
@@ -50,8 +50,7 @@
   %s s, waterway.bottlenecks b
 WHERE
   ST_Intersects(b.area, s.area)
-  AND s.name = $1
-  AND b.validity && tstzrange($2, $3)`
+  AND s.name = $1`
 
 	selectLDCsSQL = `
 SELECT
@@ -203,7 +202,7 @@
 	conn := middleware.GetDBConn(req)
 
 	// Function to extract the bottleneck_id's from the query.
-	var extract func(context.Context, *sql.Conn, string, time.Time, time.Time) (bottlenecks, error)
+	var extract func(context.Context, *sql.Conn, string) (bottlenecks, error)
 
 	switch vars["kind"] {
 	case "bottleneck":
@@ -217,7 +216,7 @@
 		return
 	}
 
-	bottlenecks, err := extract(ctx, conn, name, from, to)
+	bottlenecks, err := extract(ctx, conn, name)
 	if err != nil {
 		log.Printf("error: %v\n", err)
 		http.Error(rw, "cannot extract bottlenecks", http.StatusBadRequest)
@@ -628,14 +627,12 @@
 	ctx context.Context,
 	conn *sql.Conn,
 	what, name string,
-	from, to time.Time,
 ) (bottlenecks, error) {
 
 	rows, err := conn.QueryContext(
 		ctx,
 		fmt.Sprintf(selectSymbolBottlenecksSQL, what),
-		name,
-		from, to)
+		name)
 	if err != nil {
 		return nil, err
 	}
@@ -658,7 +655,6 @@
 	_ context.Context,
 	_ *sql.Conn,
 	name string,
-	_, _ time.Time,
 ) (bottlenecks, error) {
 	return bottlenecks{{id: name}}, nil
 }
@@ -667,26 +663,22 @@
 	ctx context.Context,
 	conn *sql.Conn,
 	name string,
-	from, to time.Time,
 ) (bottlenecks, error) {
 	return loadSymbolBottlenecksFromTo(
 		ctx,
 		conn,
-		"users.stretches", name,
-		from, to)
+		"users.stretches", name)
 }
 
 func extractSection(
 	ctx context.Context,
 	conn *sql.Conn,
 	name string,
-	from, to time.Time,
 ) (bottlenecks, error) {
 	return loadSymbolBottlenecksFromTo(
 		ctx,
 		conn,
-		"waterway.sections", name,
-		from, to)
+		"waterway.sections", name)
 }
 
 func (bn *bottleneck) loadLimitingValidities(