Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forgotten geom in search #2934

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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