seems fine
This commit is contained in:
parent
48983e3b4b
commit
7a1696541f
37 changed files with 4999 additions and 1242 deletions
|
|
@ -22,6 +22,8 @@ pub struct PostcodePropertiesParams {
|
|||
pub filters: Option<String>,
|
||||
pub limit: Option<usize>,
|
||||
pub offset: Option<usize>,
|
||||
/// 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.
|
||||
pub share: Option<String>,
|
||||
}
|
||||
|
|
@ -67,6 +69,12 @@ pub async fn get_postcode_properties(
|
|||
let filters_str = params.filters;
|
||||
|
||||
let postcode_str = normalized;
|
||||
let focus_address = params
|
||||
.focus_address
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|address| !address.is_empty())
|
||||
.map(str::to_ascii_lowercase);
|
||||
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
let t0 = std::time::Instant::now();
|
||||
|
|
@ -100,7 +108,20 @@ pub async fn get_postcode_properties(
|
|||
}
|
||||
});
|
||||
|
||||
matching_rows.sort_unstable_by_key(|&row| state.data.address(row).trim().is_empty());
|
||||
matching_rows.sort_unstable_by(|&left, &right| {
|
||||
let left_address = state.data.address(left).trim();
|
||||
let right_address = state.data.address(right).trim();
|
||||
let left_focused = focus_address
|
||||
.as_ref()
|
||||
.is_some_and(|address| left_address.eq_ignore_ascii_case(address));
|
||||
let right_focused = focus_address
|
||||
.as_ref()
|
||||
.is_some_and(|address| right_address.eq_ignore_ascii_case(address));
|
||||
|
||||
right_focused
|
||||
.cmp(&left_focused)
|
||||
.then(left_address.is_empty().cmp(&right_address.is_empty()))
|
||||
});
|
||||
|
||||
let total = matching_rows.len();
|
||||
let limit = params
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue