mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Allow users with no invites to be fetched from the API
This commit is contained in:
parent
b0eb692760
commit
4da3005b5c
2 changed files with 13 additions and 6 deletions
|
@ -229,6 +229,7 @@ async fn create_users(
|
|||
Ok(Json(users))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct GetUsersWithNoInvites {
|
||||
invited_by_another_user: bool,
|
||||
}
|
||||
|
|
|
@ -262,15 +262,17 @@ impl Db for PostgresDb {
|
|||
}
|
||||
|
||||
async fn get_users_with_no_invites(&self, invited_by_another_user: bool) -> Result<Vec<User>> {
|
||||
let query = "
|
||||
let query = format!(
|
||||
"
|
||||
SELECT users.*
|
||||
FROM users
|
||||
WHERE invite_count = 0
|
||||
";
|
||||
Ok(sqlx::query_as(query)
|
||||
.bind(&ids)
|
||||
.fetch_all(&self.pool)
|
||||
.await?)
|
||||
AND inviter_id IS{} NULL
|
||||
",
|
||||
if invited_by_another_user { " NOT" } else { "" }
|
||||
);
|
||||
|
||||
Ok(sqlx::query_as(&query).fetch_all(&self.pool).await?)
|
||||
}
|
||||
|
||||
async fn get_user_by_github_login(&self, github_login: &str) -> Result<Option<User>> {
|
||||
|
@ -2188,6 +2190,10 @@ pub mod tests {
|
|||
Ok(ids.iter().filter_map(|id| users.get(id).cloned()).collect())
|
||||
}
|
||||
|
||||
async fn get_users_with_no_invites(&self, _: bool) -> Result<Vec<User>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn get_user_by_github_login(&self, github_login: &str) -> Result<Option<User>> {
|
||||
Ok(self
|
||||
.users
|
||||
|
|
Loading…
Reference in a new issue