Skip to content

Commit

Permalink
Fix forgotten geom in search (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaxsze committed Dec 4, 2023
1 parent 1ed4039 commit 26802e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- `udata spatial load -d` to load new geozones into the database
- `udata spatial migrate` to migrate datasets geozones to new ones
- Reindex datasets
- Removed forgotten fields in search [#2934](https://github.com/opendatateam/udata/pull/2934)

## 6.2.0 (2023-10-26)

Expand Down
10 changes: 2 additions & 8 deletions udata/core/dataset/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,17 @@ def serialize(cls, dataset):
})

if dataset.spatial is not None:
# Index precise zone labels and parents zone identifiers
# to allow fast filtering.
# Index precise zone labels to allow fast filtering.
zone_ids = [z.id for z in dataset.spatial.zones]
zones = GeoZone.objects(id__in=zone_ids).exclude('geom')
parents = set()
zones = GeoZone.objects(id__in=zone_ids)
geozones = []
coverage_level = ADMIN_LEVEL_MAX
for zone in zones:
geozones.append({
'id': zone.id,
'name': zone.name,
'keys': zone.keys_values
})
parents |= set(zone.parents)
coverage_level = min(coverage_level, admin_levels[zone.level])

geozones.extend([{'id': p} for p in parents])
document.update({
'geozones': geozones,
'granularity': dataset.spatial.granularity,
Expand Down

0 comments on commit 26802e8

Please sign in to comment.