diff --git a/Cargo.lock b/Cargo.lock index ebadb67..7415c87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "auto-frs-schedule" -version = "2.3.0" +version = "2.4.1" dependencies = [ "anyhow", "calamine", diff --git a/Cargo.toml b/Cargo.toml index 88dfd48..6afe22c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "auto-frs-schedule" -version = "2.3.0" +version = "2.4.1" edition = "2021" description = "Automatically generate TC FRS schedule from Excel file" authors = ["Mohamad Kholid Bughowi "] diff --git a/src/commands/clean.rs b/src/commands/clean.rs index 1ce28dc..dcbbfab 100644 --- a/src/commands/clean.rs +++ b/src/commands/clean.rs @@ -1,9 +1,8 @@ -use anyhow::Result; use sqlx::{MySql, Pool}; use crate::db::repository::{many_to_many_repository::ManyToManyRepository, Repository}; -pub async fn clean_handler(pool: &Pool) -> Result<()> { +pub async fn clean_handler(pool: &Pool) { log::info!("Clean up invalid foreign key"); let many_to_many_repo = ManyToManyRepository::new(pool); let clean_class_to_plan = many_to_many_repo.drop_invalid_class_to_plan(); @@ -14,5 +13,4 @@ pub async fn clean_handler(pool: &Pool) -> Result<()> { Ok(_) => log::info!("Cleaning completed successfully"), Err(e) => log::error!("Cleaning failed: {}", e), } - Ok(()) } diff --git a/src/commands/sync.rs b/src/commands/sync.rs index 93b2519..935715d 100644 --- a/src/commands/sync.rs +++ b/src/commands/sync.rs @@ -1,11 +1,10 @@ -use anyhow::Result; use sqlx::{MySql, Pool}; use crate::db::repository::{ class_repository::ClassRepository, plan_repository::PlanRepository, Repository, }; -pub async fn sync_handler(pool: &Pool) -> Result<()> { +pub async fn sync_handler(pool: &Pool) { log::info!("Sync taken from Class"); let class_repo = ClassRepository::new(pool); @@ -16,5 +15,4 @@ pub async fn sync_handler(pool: &Pool) -> Result<()> { Ok(_) => log::info!("Succesfully sync taken and totalSks from Class and Plan table"), Err(e) => log::error!("Error sync : {}", e), } - Ok(()) } diff --git a/src/commands/update.rs b/src/commands/update.rs index be53bf6..65e3c1f 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -39,9 +39,10 @@ pub async fn update_handler( let handle = tokio::task::spawn(async move { log::info!("Insert {} classes to DB", cloned_list_class.len()); let class_repo = ClassRepository::new(&cloned_pool); - if let Err(e) = class_repo.insert_classes(&cloned_list_class).await { - log::error!("Error inserting class to DB: {}", e); - } + class_repo + .insert_classes(&cloned_list_class) + .await + .expect("Error inserting class to DB"); }); handles.push(handle); } diff --git a/src/main.rs b/src/main.rs index 8599b5c..15957b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,10 +52,10 @@ async fn main() -> Result<()> { outdir, } => commands::compare::compare_handler(file, sheet, outdir, &pool).await?, Commands::Clean => { - commands::clean::clean_handler(&pool).await?; + commands::clean::clean_handler(&pool).await; } Commands::Sync => { - commands::sync::sync_handler(&pool).await?; + commands::sync::sync_handler(&pool).await; } }