.
This commit is contained in:
parent
f99bd4e5c9
commit
a04ac2d857
16 changed files with 132 additions and 74 deletions
|
|
@ -208,7 +208,7 @@ struct ParsedPostcodeList {
|
|||
fn parse_postcode_list(
|
||||
raw: &str,
|
||||
state: &crate::state::AppState,
|
||||
) -> Result<ParsedPostcodeList, axum::response::Response> {
|
||||
) -> Result<ParsedPostcodeList, (StatusCode, String)> {
|
||||
let mut entries: Vec<(usize, String)> = Vec::new();
|
||||
let mut unknown: Vec<String> = Vec::new();
|
||||
let mut seen: FxHashSet<usize> = FxHashSet::default();
|
||||
|
|
@ -229,8 +229,7 @@ fn parse_postcode_list(
|
|||
"Too many postcodes; at most {} are supported per export",
|
||||
MAX_EXPORT_POSTCODES
|
||||
),
|
||||
)
|
||||
.into_response());
|
||||
));
|
||||
}
|
||||
match state.postcode_data.postcode_to_idx.get(&normalized) {
|
||||
Some(&pc_idx) if seen.insert(pc_idx) => {
|
||||
|
|
@ -245,8 +244,7 @@ fn parse_postcode_list(
|
|||
return Err((
|
||||
StatusCode::BAD_REQUEST,
|
||||
"No valid postcodes supplied".to_string(),
|
||||
)
|
||||
.into_response());
|
||||
));
|
||||
}
|
||||
|
||||
Ok(ParsedPostcodeList { entries, unknown })
|
||||
|
|
@ -296,7 +294,9 @@ pub async fn get_export(
|
|||
|
||||
// Two modes: bounds-based (default) and explicit postcode list.
|
||||
let postcode_list = match params.postcodes.as_deref() {
|
||||
Some(raw) if !raw.trim().is_empty() => Some(parse_postcode_list(raw, &state)?),
|
||||
Some(raw) if !raw.trim().is_empty() => {
|
||||
Some(parse_postcode_list(raw, &state).map_err(IntoResponse::into_response)?)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let is_postcode_mode = postcode_list.is_some();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue