This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
2024-08-04 12:34:46 +03:00

20 lines
485 B
Rust

use crate::prelude::*;
#[derive(Deserialize, Debug)]
pub struct Params {
search_string: String,
}
pub async fn search(
State(pool): State<Pool>,
Query(params): Query<Params>,
) -> sqlx::Result<Json<Vec<db::users::UserSearch>>, StatusCode> {
db::users::search_for_user(&params.search_string, &pool)
.take(20)
.try_filter(|user| future::ready(user.similarity > 0.1))
.try_collect()
.await
.handle_internal()
.map(Json)
}