skip the selection-edge query where nothing reads it
The temporal timeline summarises every snapshot in a series. Each summary now also counts how many features the selection edge cuts, but a timeline point renders values only, so that was one database round trip per snapshot for a disclosure nobody sees. Make it opt-out and have the timeline opt out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user