all is well
This commit is contained in:
parent
eac1bd0d13
commit
2f149503bb
53 changed files with 1543 additions and 354 deletions
|
|
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||
use tracing::info;
|
||||
|
||||
use crate::api_error::ApiError;
|
||||
use crate::consts::{DEFAULT_ACTUAL_LISTINGS_LIMIT, MAX_ACTUAL_LISTINGS_LIMIT};
|
||||
use crate::consts::ACTUAL_LISTINGS_LIMIT;
|
||||
use crate::data::ActualListing;
|
||||
use crate::features::property_level_feature_names;
|
||||
use crate::parsing::{
|
||||
|
|
@ -24,9 +24,6 @@ pub struct ActualListingsParams {
|
|||
filters: Option<String>,
|
||||
/// Pipe-separated travel time entries: `mode:slug|mode:slug:min:max`
|
||||
travel: Option<String>,
|
||||
/// Page size — defaults to DEFAULT_ACTUAL_LISTINGS_LIMIT, capped at
|
||||
/// MAX_ACTUAL_LISTINGS_LIMIT.
|
||||
limit: Option<usize>,
|
||||
/// Number of results to skip. Defaults to 0.
|
||||
offset: Option<usize>,
|
||||
}
|
||||
|
|
@ -35,7 +32,6 @@ pub struct ActualListingsParams {
|
|||
pub struct ActualListingsResponse {
|
||||
pub listings: Vec<ActualListing>,
|
||||
pub total: usize,
|
||||
pub limit: usize,
|
||||
pub offset: usize,
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
|
@ -45,16 +41,12 @@ pub async fn get_actual_listings(
|
|||
Query(params): Query<ActualListingsParams>,
|
||||
) -> Result<Json<ActualListingsResponse>, ApiError> {
|
||||
let state = shared.load_state();
|
||||
let limit = params
|
||||
.limit
|
||||
.unwrap_or(DEFAULT_ACTUAL_LISTINGS_LIMIT)
|
||||
.min(MAX_ACTUAL_LISTINGS_LIMIT);
|
||||
let limit = ACTUAL_LISTINGS_LIMIT;
|
||||
let offset = params.offset.unwrap_or(0);
|
||||
let Some(actual_listings) = state.actual_listings.clone() else {
|
||||
return Ok(Json(ActualListingsResponse {
|
||||
listings: Vec::new(),
|
||||
total: 0,
|
||||
limit,
|
||||
offset,
|
||||
truncated: false,
|
||||
}));
|
||||
|
|
@ -162,7 +154,6 @@ pub async fn get_actual_listings(
|
|||
Ok(ActualListingsResponse {
|
||||
listings,
|
||||
total: total_matching,
|
||||
limit,
|
||||
offset,
|
||||
truncated,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue