Skip to content

Commit

Permalink
feat: more informatif log message and simplify task join
Browse files Browse the repository at this point in the history
  • Loading branch information
albugowy15 committed Apr 14, 2024
1 parent 7d63919 commit 6be2be2
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 158 deletions.
117 changes: 62 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ calamine = "0.24.0"
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
cuid = "1.3.2"
clap = { version = "4.5.4", features = ["derive"] }
anyhow = "1.0.81"
anyhow = "1.0.82"
sqlx = { version = "0.7", features = [
"runtime-tokio",
"tls-native-tls",
Expand Down
7 changes: 2 additions & 5 deletions src/commands/clean.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use tokio::try_join;

use crate::db::{
self,
repository::{many_to_many::ManyToManyRepository, Repository},
};

pub async fn clean_handler() -> anyhow::Result<()> {
println!("Open db connection...");
let pool = db::Database::create_connection().await?;
println!("Clean up invalid foreign key");
let many_to_many_repo = ManyToManyRepository::new(&pool);

try_join!(
tokio::try_join!(
many_to_many_repo.drop_invalid_class_to_plan(),
many_to_many_repo.drop_invalid_class_to_lecturer()
)?;
pool.close().await;
println!("Closing databse connection");
println!("Done");
Ok(())
}
Loading

0 comments on commit 6be2be2

Please sign in to comment.