API: don't return people with no availability

This commit is contained in:
Ben Grant 2023-05-28 22:35:33 +10:00
parent 2d9b1d7959
commit cdea567bf3

View file

@ -38,7 +38,18 @@ pub async fn get_people<A: Adaptor>(
.map_err(ApiError::AdaptorError)?; .map_err(ApiError::AdaptorError)?;
match people { match people {
Some(people) => Ok(Json(people.into_iter().map(|p| p.into()).collect())), Some(people) => Ok(Json(
people
.into_iter()
.filter_map(|p| {
if !p.availability.is_empty() {
Some(p.into())
} else {
None
}
})
.collect(),
)),
None => Err(ApiError::NotFound), None => Err(ApiError::NotFound),
} }
} }