# HG changeset patch # User Sascha Wilde # Date 1589317401 -7200 # Node ID 13e1767b63a172b2b44d44ff1e5c72196ff2fbdc # Parent d855426a6e5d7ea1e821e51b51087bfce8366445 Reverted: 8c44b518141a, which didn't fix anything. diff -r d855426a6e5d -r 13e1767b63a1 pkg/controllers/fwa.go --- a/pkg/controllers/fwa.go Tue May 12 22:55:10 2020 +0200 +++ b/pkg/controllers/fwa.go Tue May 12 23:03:21 2020 +0200 @@ -50,7 +50,8 @@ %s s, waterway.bottlenecks b WHERE ST_Intersects(b.area, s.area) - AND s.name = $1` + AND s.name = $1 + AND b.validity && tstzrange($2, $3)` selectLDCsSQL = ` SELECT @@ -202,7 +203,7 @@ conn := middleware.GetDBConn(req) // Function to extract the bottleneck_id's from the query. - var extract func(context.Context, *sql.Conn, string) (bottlenecks, error) + var extract func(context.Context, *sql.Conn, string, time.Time, time.Time) (bottlenecks, error) switch vars["kind"] { case "bottleneck": @@ -216,7 +217,7 @@ return } - bottlenecks, err := extract(ctx, conn, name) + bottlenecks, err := extract(ctx, conn, name, from, to) if err != nil { log.Printf("error: %v\n", err) http.Error(rw, "cannot extract bottlenecks", http.StatusBadRequest) @@ -627,12 +628,14 @@ 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) + name, + from, to) if err != nil { return nil, err } @@ -655,6 +658,7 @@ _ context.Context, _ *sql.Conn, name string, + _, _ time.Time, ) (bottlenecks, error) { return bottlenecks{{id: name}}, nil } @@ -663,22 +667,26 @@ ctx context.Context, conn *sql.Conn, name string, + from, to time.Time, ) (bottlenecks, error) { return loadSymbolBottlenecksFromTo( ctx, conn, - "users.stretches", name) + "users.stretches", name, + from, to) } func extractSection( ctx context.Context, conn *sql.Conn, name string, + from, to time.Time, ) (bottlenecks, error) { return loadSymbolBottlenecksFromTo( ctx, conn, - "waterway.sections", name) + "waterway.sections", name, + from, to) } func (bn *bottleneck) loadLimitingValidities(