diff --git a/backend/app/services/temporal_analysis_service.py b/backend/app/services/temporal_analysis_service.py index bb1d7f10..432b6212 100644 --- a/backend/app/services/temporal_analysis_service.py +++ b/backend/app/services/temporal_analysis_service.py @@ -171,11 +171,15 @@ class TemporalAnalysisService: summaries: dict[UUID, dict[str, Any]] = {} - def summarize(dataset: Dataset) -> dict[str, Any]: + def summarize(dataset: Dataset, *, disclose_selection_edge: bool = True) -> dict[str, Any]: cached = summaries.get(dataset.id) if cached is not None: return cached - kwargs: dict[str, Any] = {"dataset": dataset, "bbox": bbox} + kwargs: dict[str, Any] = { + "dataset": dataset, + "bbox": bbox, + "disclose_selection_edge": disclose_selection_edge, + } if selection_area is not None: dataset_is_preclipped = is_preclipped_to_selection_area(dataset) kwargs["selection_geometry"] = None if dataset_is_preclipped else selection_geometry @@ -234,7 +238,9 @@ class TemporalAnalysisService: project_id=project_id, series_key=earlier.temporal_series_key, fallback_datasets=[earlier, later], - summarize=summarize, + # A timeline point shows values only, so the per-snapshot + # selection-edge query would be a round trip nobody reads. + summarize=lambda dataset: summarize(dataset, disclose_selection_edge=False), ) return TemporalComparisonResponse( diff --git a/backend/app/services/vector_feature_service.py b/backend/app/services/vector_feature_service.py index b47e11af..2249de00 100644 --- a/backend/app/services/vector_feature_service.py +++ b/backend/app/services/vector_feature_service.py @@ -811,6 +811,7 @@ class VectorFeatureService: selection_geometry: Any | None = None, full_dataset_area: bool = False, preclipped_partition_filter: tuple[str, str] | None = None, + disclose_selection_edge: bool = True, ) -> dict[str, Any]: normalized_bbox = VectorFeatureService._normalize_selection_bbox(bbox) selection_shape = selection_geometry @@ -842,7 +843,7 @@ class VectorFeatureService: # How many of the counted features the selection edge cuts. Skipped for # a pre-clipped whole-area selection, which has no edge to cut against. fully_covered_feature_count: int | None = None - if not full_dataset_area and feature_count: + if disclose_selection_edge and not full_dataset_area and feature_count: try: fully_covered_feature_count = int( db.query(func.count(VectorFeature.id)) diff --git a/backend/tests/test_sprint187_temporal_map_foundation.py b/backend/tests/test_sprint187_temporal_map_foundation.py index 3c25ad36..21daaa41 100644 --- a/backend/tests/test_sprint187_temporal_map_foundation.py +++ b/backend/tests/test_sprint187_temporal_map_foundation.py @@ -320,7 +320,7 @@ def test_temporal_compare_returns_delta_and_canonical_change_payload(monkeypatch def get_dataset(_db, _project_id, dataset_id, _label): return earlier if dataset_id == earlier.id else later - def summarize(_db, *, dataset, bbox): # noqa: ARG001 + def summarize(_db, *, dataset, bbox, disclose_selection_edge=True): # noqa: ARG001 value = 100.0 if dataset.id == earlier.id else 115.0 return { "metric_label": "Inwoners", @@ -386,7 +386,7 @@ def test_temporal_comparison_clips_cross_boundary_bbox_to_selected_area(monkeypa staticmethod(lambda _db, _project_id, requested_area_id: area if requested_area_id == area_id else None), ) - def summarize(_db, *, dataset, bbox, selection_geometry, full_dataset_area): # noqa: ARG001 + def summarize(_db, *, dataset, bbox, selection_geometry, full_dataset_area, disclose_selection_edge=True): # noqa: ARG001 captured_geometries.append(selection_geometry) return { "metric_label": "Oppervlakte",