restrict postcode distance computation to within country

This commit is contained in:
Sarah Hoffmann
2025-07-11 20:20:37 +02:00
parent 6d2b79870c
commit 1fe2353682

View File

@@ -233,6 +233,7 @@ class AddressSearch(base.AbstractSearch):
pc_near = sa.select(sa.func.min(tpc.c.geometry.ST_Distance(t.c.centroid)
* (tpc.c.rank_search - 19)))\
.where(tpc.c.postcode.in_(pcs))\
.where(tpc.c.country_code == t.c.country_code)\
.scalar_subquery()
penalty += sa.case((t.c.postcode.in_(pcs), 0.0),
else_=sa.func.coalesce(pc_near, cast(SaColumn, 2.0)))