Skip to content

Commit

Permalink
fix: Update version and clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
albugowy15 committed Dec 4, 2023
1 parent 9922c3b commit 103e212
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion 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
@@ -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 <[email protected]>"]
Expand Down
4 changes: 1 addition & 3 deletions src/commands/clean.rs
Original file line number Diff line number Diff line change
@@ -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<MySql>) -> Result<()> {
pub async fn clean_handler(pool: &Pool<MySql>) {
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();
Expand All @@ -14,5 +13,4 @@ pub async fn clean_handler(pool: &Pool<MySql>) -> Result<()> {
Ok(_) => log::info!("Cleaning completed successfully"),
Err(e) => log::error!("Cleaning failed: {}", e),
}
Ok(())
}
4 changes: 1 addition & 3 deletions src/commands/sync.rs
Original file line number Diff line number Diff line change
@@ -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<MySql>) -> Result<()> {
pub async fn sync_handler(pool: &Pool<MySql>) {
log::info!("Sync taken from Class");
let class_repo = ClassRepository::new(pool);

Expand All @@ -16,5 +15,4 @@ pub async fn sync_handler(pool: &Pool<MySql>) -> Result<()> {
Ok(_) => log::info!("Succesfully sync taken and totalSks from Class and Plan table"),
Err(e) => log::error!("Error sync : {}", e),
}
Ok(())
}
7 changes: 4 additions & 3 deletions src/commands/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 103e212

Please sign in to comment.