Lint
This commit is contained in:
parent
4a0f00f2a4
commit
18ace123dc
13 changed files with 59 additions and 33 deletions
|
|
@ -914,8 +914,7 @@ impl PropertyData {
|
|||
|
||||
// Re-key tenure_history by permuted row index
|
||||
let tenure_history: FxHashMap<u32, Vec<TenureEvent>> = {
|
||||
let mut map =
|
||||
FxHashMap::with_capacity_and_hasher(tenure_raw.len(), Default::default());
|
||||
let mut map = FxHashMap::with_capacity_and_hasher(tenure_raw.len(), Default::default());
|
||||
for (new_row, &old_row) in perm.iter().enumerate() {
|
||||
if let Some(events) = tenure_raw.remove(&old_row) {
|
||||
map.insert(new_row as u32, events);
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ fn demo_center_from_query(query: Option<&str>) -> Option<(f64, f64)> {
|
|||
|
||||
/// Resolve a request's demo zone from its query params, falling back to Canary Wharf.
|
||||
pub fn resolve_demo_zone(query: Option<&str>) -> DemoZone {
|
||||
let (lat, lon) = demo_center_from_query(query)
|
||||
.unwrap_or((FREE_ZONE_FALLBACK_LAT, FREE_ZONE_FALLBACK_LON));
|
||||
let (lat, lon) =
|
||||
demo_center_from_query(query).unwrap_or((FREE_ZONE_FALLBACK_LAT, FREE_ZONE_FALLBACK_LON));
|
||||
DemoZone {
|
||||
free_zone: free_zone_around(lat, lon),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use url::form_urlencoded;
|
|||
|
||||
use crate::auth::PocketBaseUser;
|
||||
use crate::consts::{
|
||||
MAX_SHARE_LAT_SPAN, MAX_SHARE_LON_SPAN, MAX_SHARE_ZOOM, MIN_SHARE_ZOOM, SHARE_CACHE_MAX_ENTRIES,
|
||||
SHARE_CACHE_TTL_SECS,
|
||||
MAX_SHARE_LAT_SPAN, MAX_SHARE_LON_SPAN, MAX_SHARE_ZOOM, MIN_SHARE_ZOOM,
|
||||
SHARE_CACHE_MAX_ENTRIES, SHARE_CACHE_TTL_SECS,
|
||||
};
|
||||
use crate::demo_zone::FreeZone;
|
||||
use crate::pocketbase::get_superuser_token;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,10 @@ fn is_internal_request(headers: &HeaderMap, peer: Option<IpAddr>) -> bool {
|
|||
fn filter_count(query: &str) -> usize {
|
||||
for (key, value) in form_urlencoded::parse(query.as_bytes()) {
|
||||
if key == "filters" {
|
||||
return value.split(";;").filter(|entry| !entry.trim().is_empty()).count();
|
||||
return value
|
||||
.split(";;")
|
||||
.filter(|entry| !entry.trim().is_empty())
|
||||
.count();
|
||||
}
|
||||
}
|
||||
0
|
||||
|
|
@ -157,7 +160,10 @@ pub async fn demo_guard_middleware(req: Request, next: Next) -> Response {
|
|||
}
|
||||
|
||||
// Licensed users and admins bypass demo guards entirely.
|
||||
let user = req.extensions().get::<OptionalUser>().and_then(|u| u.0.clone());
|
||||
let user = req
|
||||
.extensions()
|
||||
.get::<OptionalUser>()
|
||||
.and_then(|u| u.0.clone());
|
||||
if let Some(u) = &user {
|
||||
if u.is_admin || u.subscription == "licensed" {
|
||||
return next.run(req).await;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,12 @@ pub async fn get_actual_listings(
|
|||
require_bounds(params.bounds).map_err(IntoResponse::into_response)?;
|
||||
|
||||
let share_bounds = resolve_share_code(&state, params.share.as_deref()).await;
|
||||
check_license_bounds(&user.0, (south, west, north, east), geo.free_zone, share_bounds)?;
|
||||
check_license_bounds(
|
||||
&user.0,
|
||||
(south, west, north, east),
|
||||
geo.free_zone,
|
||||
share_bounds,
|
||||
)?;
|
||||
|
||||
let quant = state.data.quant_ref();
|
||||
let poi_quant = state.data.poi_metrics.quant_ref();
|
||||
|
|
|
|||
|
|
@ -502,7 +502,12 @@ pub async fn get_export(
|
|||
}
|
||||
|
||||
let share_bounds = resolve_share_code(&state, params.share.as_deref()).await;
|
||||
check_license_bounds(&user.0, (south, west, north, east), geo.free_zone, share_bounds)?;
|
||||
check_license_bounds(
|
||||
&user.0,
|
||||
(south, west, north, east),
|
||||
geo.free_zone,
|
||||
share_bounds,
|
||||
)?;
|
||||
|
||||
let quant = state.data.quant_ref();
|
||||
let poi_quant = state.data.poi_metrics.quant_ref();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,12 @@ pub async fn get_filter_counts(
|
|||
let (south, west, north, east) =
|
||||
require_bounds(params.bounds).map_err(IntoResponse::into_response)?;
|
||||
let share_bounds = resolve_share_code(&state, params.share.as_deref()).await;
|
||||
check_license_bounds(&user.0, (south, west, north, east), geo.free_zone, share_bounds)?;
|
||||
check_license_bounds(
|
||||
&user.0,
|
||||
(south, west, north, east),
|
||||
geo.free_zone,
|
||||
share_bounds,
|
||||
)?;
|
||||
|
||||
let quant = state.data.quant_ref();
|
||||
let poi_quant = state.data.poi_metrics.quant_ref();
|
||||
|
|
|
|||
|
|
@ -263,7 +263,12 @@ pub async fn get_hexagons(
|
|||
require_bounds(params.bounds).map_err(IntoResponse::into_response)?;
|
||||
|
||||
let share_bounds = resolve_share_code(&state, params.share.as_deref()).await;
|
||||
check_license_bounds(&user.0, (south, west, north, east), geo.free_zone, share_bounds)?;
|
||||
check_license_bounds(
|
||||
&user.0,
|
||||
(south, west, north, east),
|
||||
geo.free_zone,
|
||||
share_bounds,
|
||||
)?;
|
||||
|
||||
let quant = state.data.quant_ref();
|
||||
let poi_quant = state.data.poi_metrics.quant_ref();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,12 @@ pub async fn get_postcodes(
|
|||
require_bounds(params.bounds).map_err(IntoResponse::into_response)?;
|
||||
|
||||
let share_bounds = resolve_share_code(&state, params.share.as_deref()).await;
|
||||
check_license_bounds(&user.0, (south, west, north, east), geo.free_zone, share_bounds)?;
|
||||
check_license_bounds(
|
||||
&user.0,
|
||||
(south, west, north, east),
|
||||
geo.free_zone,
|
||||
share_bounds,
|
||||
)?;
|
||||
|
||||
let quant = state.data.quant_ref();
|
||||
let poi_quant = state.data.poi_metrics.quant_ref();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue