# HG changeset patch # User Sascha Wilde # Date 1713538334 -7200 # Node ID 0500d76e074b0fb3faccc23d6cb7b85478148e02 # Parent 5ca33ef30916c4bb5b32bb7b7b84ad441e1f24cd 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. diff -r 5ca33ef30916 -r 0500d76e074b pkg/imports/wg.go --- 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