Mercurial > gemma
diff pkg/imports/wg.go @ 3551:a5448426e4e2
Only erase gauges that have been requested from ERDMS
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 31 May 2019 14:16:48 +0200 |
parents | ba0339118d9c |
children | 02951a62e8c6 |
line wrap: on
line diff
--- a/pkg/imports/wg.go Fri May 31 13:59:54 2019 +0200 +++ b/pkg/imports/wg.go Fri May 31 14:16:48 2019 +0200 @@ -67,7 +67,9 @@ const ( eraseObsoleteGaugesSQL = ` UPDATE waterway.gauges SET erased = true -WHERE NOT erased AND isrs_astext(location) <> ALL($1) +WHERE NOT erased + AND (location).country_code = ANY($1) + AND isrs_astext(location) <> ALL($2) RETURNING isrs_astext(location) ` @@ -184,7 +186,7 @@ start := time.Now() - responseData, err := getRisData( + responseData, countries, err := getRisData( ctx, conn, feedback, @@ -515,9 +517,13 @@ return nil, UnchangedError("No gauges returned from ERDMS") } - var pgGauges pgtype.VarcharArray + var pgCountries, pgGauges pgtype.VarcharArray + pgCountries.Set(countries) pgGauges.Set(gauges) - obsGauges, err := conn.QueryContext(ctx, eraseObsoleteGaugesSQL, &pgGauges) + obsGauges, err := conn.QueryContext(ctx, + eraseObsoleteGaugesSQL, + &pgCountries, + &pgGauges) if err != nil { return nil, err }