From 6ed28994c622c30412e72bfcaf9cfb7bde1a851a Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 21 Feb 2024 14:46:17 +0100 Subject: [PATCH] code cleanup --- src/lib.rs | 2 ++ src/main.rs | 2 ++ src/model/family.rs | 2 +- src/model/mail.rs | 2 +- src/model/user.rs | 10 ++++------ src/tera/log.rs | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fbc4b0e..8ead4e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::blocks_in_conditions)] + pub mod model; #[cfg(feature = "rowing-tera")] diff --git a/src/main.rs b/src/main.rs index 64608e7..ef60226 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::blocks_in_conditions)] + use std::str::FromStr; #[cfg(feature = "rest")] diff --git a/src/model/family.rs b/src/model/family.rs index a3ea998..f648cfd 100644 --- a/src/model/family.rs +++ b/src/model/family.rs @@ -22,7 +22,7 @@ impl Family { .unwrap() } - pub async fn new(db: &SqlitePool) -> i64 { + pub async fn insert(db: &SqlitePool) -> i64 { let result: SqliteQueryResult = sqlx::query("INSERT INTO family DEFAULT VALUES") .execute(db) .await diff --git a/src/model/mail.rs b/src/model/mail.rs index 6df129c..d82b8e5 100644 --- a/src/model/mail.rs +++ b/src/model/mail.rs @@ -96,7 +96,7 @@ impl Mail { } None => { if let Some(mail) = &user.mail { - send_to.push_str(&mail) + send_to.push_str(mail) } } } diff --git a/src/model/user.rs b/src/model/user.rs index bb44320..0127609 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -128,7 +128,7 @@ impl Fee { pub fn add_person(&mut self, user: &User) { if !self.name.is_empty() { self.name.push_str(" + "); - self.user_ids.push_str("&"); + self.user_ids.push('&'); } self.name.push_str(&user.name); @@ -171,7 +171,7 @@ impl User { fee.add("Familie 2 Personen".into(), FAMILY_TWO); } } else { - fee.add_person(&self); + fee.add_person(self); if self.has_role(db, "paid").await { fee.paid(); } @@ -440,7 +440,7 @@ ORDER BY last_access DESC let mut family_id = data.family_id; if family_id.is_some_and(|x| x == -1) { - family_id = Some(Family::new(db).await) + family_id = Some(Family::insert(db).await) } sqlx::query!( @@ -779,9 +779,7 @@ impl<'r> FromRequest<'r> for AllowedForPlannedTripsUser { let db = req.rocket().state::().unwrap(); match User::from_request(req).await { Outcome::Success(user) => { - if user.has_role(db, "Donau Linz").await { - Outcome::Success(AllowedForPlannedTripsUser(user)) - } else if user.has_role(db, "scheckbuch").await { + if user.has_role(db, "Donau Linz").await | user.has_role(db, "scheckbuch").await { Outcome::Success(AllowedForPlannedTripsUser(user)) } else { Outcome::Error((Status::Forbidden, LoginError::NotACox)) diff --git a/src/tera/log.rs b/src/tera/log.rs index 6d6c815..09fa2c6 100644 --- a/src/tera/log.rs +++ b/src/tera/log.rs @@ -171,7 +171,7 @@ async fn create_logbook( match Logbook::create( db, data.into_inner(), - &user + user ) .await { -- 2.45.2