fix: normalize official agricultural crop groups
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-15 15:53:10 +02:00
parent 7f1064ff1e
commit 312400759f
4 changed files with 39 additions and 1 deletions
+21 -1
View File
@@ -101,8 +101,25 @@ SEMANTIC_COUNT_LABELS = {
"agriculture": "Landbouwgebruikspercelen",
}
# Sprint 205 initially normalized two official comma-separated ALZ group labels
# mechanically. Keep those persisted values queryable while new artifacts use
# the explicit controlled keys.
SELECTION_FILTER_VALUE_ALIASES: dict[tuple[str, str], tuple[str, ...]] = {
("main_crop_group_key", "grains_seeds_legumes"): ("granen,_zaden_en_peulvruchten",),
("main_crop_group_key", "horticulture"): ("groenten,_kruiden_en_sierplanten",),
}
class VectorFeatureService:
@staticmethod
def _expanded_selection_filter_values(filter_property: str, filter_values: list[Any]) -> list[str]:
expanded: list[str] = []
for value in filter_values:
normalized = str(value)
expanded.append(normalized)
expanded.extend(SELECTION_FILTER_VALUE_ALIASES.get((filter_property, normalized), ()))
return list(dict.fromkeys(expanded))
@staticmethod
def _dataset_theme(dataset: Dataset) -> str | None:
source_metadata = dataset.source_metadata if isinstance(dataset.source_metadata, dict) else {}
@@ -453,7 +470,10 @@ class VectorFeatureService:
details={"dataset_id": str(dataset.id), "filter_property": filter_property},
status_code=500,
)
normalized_filter_values = [str(value) for value in filter_values]
normalized_filter_values = VectorFeatureService._expanded_selection_filter_values(
filter_property,
filter_values,
)
metric_filter += (
VectorFeature.properties_json.op("->>")(filter_property).in_(normalized_filter_values),
)