Skip to content

Commit 7472c29

Browse files
authored
collab: Route fuzzy_search_users through Cloud (#56436)
This PR makes it so we route the `UserService::fuzzy_search_users` call through Cloud instead of hitting the database. Closes CLO-745. Release Notes: - N/A
1 parent 6d2b391 commit 7472c29

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

crates/cloud_api_types/src/internal_api.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ pub struct LookUpUserByGithubLoginBody {
3030
pub struct LookUpUserByGithubLoginResponse {
3131
pub user: Option<User>,
3232
}
33+
34+
#[derive(Debug, Serialize, Deserialize)]
35+
pub struct FuzzySearchUsersBody {
36+
pub query: String,
37+
pub limit: u32,
38+
}
39+
40+
#[derive(Debug, Serialize, Deserialize)]
41+
pub struct FuzzySearchUsersResponse {
42+
pub users: Vec<User>,
43+
}

crates/collab/src/services/user_service.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::sync::Arc;
33
use anyhow::{Context as _, anyhow};
44
use async_trait::async_trait;
55
use cloud_api_types::internal_api::{
6-
self, LookUpUserByGithubLoginBody, LookUpUserByGithubLoginResponse, LookUpUsersByLegacyIdBody,
7-
LookUpUsersByLegacyIdResponse,
6+
self, FuzzySearchUsersBody, FuzzySearchUsersResponse, LookUpUserByGithubLoginBody,
7+
LookUpUserByGithubLoginResponse, LookUpUsersByLegacyIdBody, LookUpUsersByLegacyIdResponse,
88
};
99
use reqwest::RequestBuilder;
1010
use rpc::proto;
@@ -74,7 +74,7 @@ impl UserService for TransitionalUserService {
7474
}
7575

7676
async fn fuzzy_search_users(&self, query: &str, limit: u32) -> Result<Vec<User>> {
77-
self.database_user_service
77+
self.cloud_user_service
7878
.fuzzy_search_users(query, limit)
7979
.await
8080
}
@@ -182,10 +182,21 @@ impl UserService for CloudUserService {
182182
}
183183

184184
async fn fuzzy_search_users(&self, query: &str, limit: u32) -> Result<Vec<User>> {
185-
let _ = query;
186-
let _ = limit;
185+
let response_body: FuzzySearchUsersResponse = self
186+
.send_request(
187+
self.http_client
188+
.post(format!(
189+
"{}/internal/users/fuzzy_search",
190+
&self.zed_cloud_url
191+
))
192+
.json(&FuzzySearchUsersBody {
193+
query: query.to_string(),
194+
limit,
195+
}),
196+
)
197+
.await?;
187198

188-
unimplemented!("not yet implemented in Cloud")
199+
Ok(response_body.users.into_iter().map(User::from).collect())
189200
}
190201

191202
async fn search_channel_members(

0 commit comments

Comments
 (0)