diff options
Diffstat (limited to 'src/controller')
| -rw-r--r-- | src/controller/balance.rs | 6 | ||||
| -rw-r--r-- | src/controller/balancing.rs | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/controller/balance.rs b/src/controller/balance.rs index 6cb937b..9398dae 100644 --- a/src/controller/balance.rs +++ b/src/controller/balance.rs @@ -6,8 +6,8 @@ use std::collections::HashMap; use crate::controller::utils; use crate::controller::wallet::Wallet; use crate::db; -use crate::model::user::User; use crate::model::balancing::Balancing; +use crate::model::user::User; use crate::payer; use crate::templates; @@ -25,7 +25,7 @@ pub async fn get(wallet: &Wallet) -> Response<Full<Bytes>> { let user_payments = with_balancing( db::payments::repartition(&wallet.db_conn).await, - db::balancing::list(&wallet.db_conn).await + db::balancing::list(&wallet.db_conn).await, ); let template_user_payments = get_template_user_payments(&users, &user_payments); @@ -74,7 +74,7 @@ fn get_template_user_incomes( fn with_balancing( user_payments: HashMap<i64, i64>, - balancings: Vec<Balancing> + balancings: Vec<Balancing>, ) -> HashMap<i64, i64> { let mut user_payments = user_payments; for balancing in balancings { diff --git a/src/controller/balancing.rs b/src/controller/balancing.rs index 718358c..c3d5ee8 100644 --- a/src/controller/balancing.rs +++ b/src/controller/balancing.rs @@ -18,7 +18,8 @@ pub async fn table( ) -> Response<Full<Bytes>> { let page = query.page.unwrap_or(1); let count = db::balancing::count(&wallet.db_conn).await; - let balancings = db::balancing::list_for_table(&wallet.db_conn, page, PER_PAGE).await; + let balancings = + db::balancing::list_for_table(&wallet.db_conn, page, PER_PAGE).await; let max_page = (count as f32 / PER_PAGE as f32).ceil() as i64; let context = minijinja::context!( @@ -70,7 +71,6 @@ async fn create_form_feedback( ) } - pub async fn create( wallet: &Wallet, query: queries::Balancing, @@ -84,8 +84,7 @@ pub async fn create( Some(balancing) => { match db::balancing::create(&wallet.db_conn, balancing).await { Some(id) => { - let row = - db::balancing::get_row(&wallet.db_conn, id).await; + let row = db::balancing::get_row(&wallet.db_conn, id).await; let page = (row - 1) / PER_PAGE + 1; utils::redirect(&format!( "/balancings?page={}&highlight={}", @@ -175,7 +174,10 @@ pub async fn delete( query: queries::Balancing, ) -> Response<Full<Bytes>> { if db::balancing::delete(&wallet.db_conn, id).await { - utils::redirect(&format!("/balancings?page={}", query.page.unwrap_or(1))) + utils::redirect(&format!( + "/balancings?page={}", + query.page.unwrap_or(1) + )) } else { update_form_feedback( id, |
