Skip to content

Commit

Permalink
found the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaro00 committed Sep 27, 2023
1 parent c019e7c commit 7cc854a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl Shuttle {
Failed,
}
// TODO replace this with self.client after PR 1275
match reqwest::get(format!("{}/project/name/{}", self.ctx.api_url(), p))
match reqwest::get(format!("{}/projects/name/{}", self.ctx.api_url(), p))
.await
.map(|r| match r.status() {
reqwest::StatusCode::NOT_FOUND => NameCheck::Available,
Expand All @@ -257,10 +257,13 @@ impl Shuttle {
break;
}
NameCheck::Taken => {
println!("Project name already taken: '{}'", p.to_string());
println!("{} {}", "Project name already taken:".red(), p);
}
NameCheck::Failed => {
println!("Failed to check if project name is available.");
println!(
"{}",
"Failed to check if project name is available.".yellow()
);
break;
}
}
Expand Down
7 changes: 3 additions & 4 deletions gateway/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,11 @@ impl GatewayService {
}

pub async fn project_name_exists(&self, project_name: &ProjectName) -> Result<(), Error> {
let a = query("SELECT project_name FROM projects WHERE project_name=?1")
query("SELECT project_name FROM projects WHERE project_name=?1")
.bind(project_name)
.fetch_optional(&self.db)
.await?;
println!("{}", a.is_some());
a.map(|_| ())
.await?
.map(|_| ())
.ok_or_else(|| Error::from_kind(ErrorKind::ProjectNotFound))
}

Expand Down

0 comments on commit 7cc854a

Please sign in to comment.