Mercurial > gemma
changeset 5721:0500d76e074b uploadwg
Fixed eraseObsoleteGaugesSQL by reintroducing matching on users CC.
The condition was removed when introducing file upload, but that leads
to too many gauges being removed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Fri, 19 Apr 2024 16:52:14 +0200 |
parents | 5ca33ef30916 |
children | 9dbef85c6bb4 |
files | pkg/imports/wg.go |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/wg.go Fri Apr 19 13:25:45 2024 +0200 +++ b/pkg/imports/wg.go Fri Apr 19 16:52:14 2024 +0200 @@ -78,7 +78,8 @@ eraseObsoleteGaugesSQL = ` UPDATE waterway.gauges SET erased = true, validity = validity - '[now,)' WHERE NOT erased - AND isrs_astext(location) <> ALL($1) + AND (location).country_code = ANY($1) + AND isrs_astext(location) <> ALL($2) RETURNING isrs_astext(location) ` @@ -566,10 +567,17 @@ return nil, UnchangedError("No gauges returned from ERDMS") } - var pgGauges pgtype.VarcharArray + countries, err := userCountries(ctx, conn) + if err != nil { + return nil, err + } + + var pgCountries, pgGauges pgtype.VarcharArray + pgCountries.Set(countries) pgGauges.Set(gauges) obsGauges, err := conn.QueryContext(ctx, eraseObsoleteGaugesSQL, + &pgCountries, &pgGauges) if err != nil { return nil, err