This commit is contained in:
Andras Schmelczer 2026-05-28 21:48:35 +01:00
parent 39ef5c6646
commit c995f12f8b
78 changed files with 4830 additions and 1619 deletions

View file

@ -10,7 +10,10 @@ use tracing::{info, warn};
use crate::auth::OptionalUser;
use crate::consts::{POSTCODE_SEARCH_OFFSET, PROPERTIES_LIMIT};
use crate::licensing::{check_license_point, resolve_share_code};
use crate::parsing::{parse_filters_with_poi, row_passes_filters, row_passes_poi_filters};
use crate::parsing::{
parse_field_indices_with_poi, parse_filters_with_poi, row_passes_filters,
row_passes_poi_filters,
};
use crate::state::SharedState;
use crate::utils::normalize_postcode;
@ -25,6 +28,10 @@ pub struct PostcodePropertiesParams {
/// Optional min:max applies as a filter (exclude properties outside range).
pub travel: Option<String>,
pub offset: Option<usize>,
/// `;;`-separated numeric feature names to include in each property payload.
/// If absent, keeps the legacy behavior and returns all numeric features.
/// If empty, returns only the fixed property card fields.
pub fields: Option<String>,
/// Exact address to rank first when opening properties from address search.
pub focus_address: Option<String>,
/// Share-link code; grants bbox-scoped access for unlicensed users.
@ -76,6 +83,17 @@ pub async fn get_postcode_properties(
let has_poi_filters = !parsed_poi_filters.is_empty();
let travel_entries = parse_optional_travel(params.travel.as_deref())
.map_err(|err| (StatusCode::BAD_REQUEST, err).into_response())?;
let field_indices = parse_field_indices_with_poi(
params.fields.as_deref(),
&state.feature_name_to_index,
&state.data.poi_metrics.name_to_index,
)
.map_err(|err| (err.0, err.1).into_response())?;
let fields_count = field_indices
.normal
.as_ref()
.map(|indices| (indices.len() + field_indices.poi.len()) as i32)
.unwrap_or(-1);
let postcode_str = normalized;
let focus_address = params
@ -165,6 +183,7 @@ pub async fn get_postcode_properties(
feature_names,
feature_name_to_index,
enum_values,
&field_indices,
)
})
.collect();
@ -177,6 +196,7 @@ pub async fn get_postcode_properties(
offset = page_offset,
filters = num_filters,
filters_raw = filters_str.as_deref().unwrap_or("-"),
fields = fields_count,
travel_entries = travel_entries.len(),
ms = format_args!("{:.1}", elapsed.as_secs_f64() * 1000.0),
"GET /api/postcode-properties"