aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris Guyonvarch2026-04-18 11:29:38 +0200
committerJoris Guyonvarch2026-04-18 11:29:38 +0200
commit26a02489721cbf81a3e8c09c095aee5ff5786275 (patch)
tree49b35339b3e5b2b2b94296a3e7cc8ea75a8c0b29 /src
parent94520e13a7f1bf45e94b4f28ea37f3703763baf7 (diff)
Format sourcesmain
Diffstat (limited to 'src')
-rw-r--r--src/controller/balance.rs6
-rw-r--r--src/controller/balancing.rs12
-rw-r--r--src/db/balancing.rs8
-rw-r--r--src/routes.rs3
-rw-r--r--src/validation/balancing.rs4
5 files changed, 20 insertions, 13 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,
diff --git a/src/db/balancing.rs b/src/db/balancing.rs
index 8914eef..379576b 100644
--- a/src/db/balancing.rs
+++ b/src/db/balancing.rs
@@ -1,7 +1,7 @@
use tokio_rusqlite::{Connection, Row, named_params};
use crate::db::utils;
-use crate::model::balancing::{Balancing, Create, Update, TableRow};
+use crate::model::balancing::{Balancing, Create, TableRow, Update};
fn row_to_balancing(row: &Row) -> Result<Balancing, rusqlite::Error> {
Ok(Balancing {
@@ -36,7 +36,11 @@ pub async fn count(conn: &Connection) -> i64 {
}
}
-pub async fn list_for_table(conn: &Connection, page: i64, per_page: i64) -> Vec<TableRow> {
+pub async fn list_for_table(
+ conn: &Connection,
+ page: i64,
+ per_page: i64,
+) -> Vec<TableRow> {
let query = r#"
SELECT
balancing.id,
diff --git a/src/routes.rs b/src/routes.rs
index 3afc822..ed8db5f 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -200,7 +200,8 @@ async fn authenticated_routes(
controller::balancing::table(&wallet, parse_query(query)).await
}
(&Method::GET, ["balancing"]) => {
- controller::balancing::create_form(&wallet, parse_query(query)).await
+ controller::balancing::create_form(&wallet, parse_query(query))
+ .await
}
(&Method::POST, ["balancing", "create"]) => {
controller::balancing::create(
diff --git a/src/validation/balancing.rs b/src/validation/balancing.rs
index 8892bca..3b70eea 100644
--- a/src/validation/balancing.rs
+++ b/src/validation/balancing.rs
@@ -13,7 +13,7 @@ pub fn create(form: &HashMap<String, String>) -> Option<Create> {
Some(Create {
source,
destination,
- amount: parse::<i64>(form, "amount")?
+ amount: parse::<i64>(form, "amount")?,
})
}
}
@@ -28,7 +28,7 @@ pub fn update(form: &HashMap<String, String>) -> Option<Update> {
Some(Update {
source,
destination,
- amount: parse::<i64>(form, "amount")?
+ amount: parse::<i64>(form, "amount")?,
})
}
}