fix many clones()

This commit is contained in:
2023-05-24 12:11:55 +02:00
parent cf45036642
commit 99296d4060
8 changed files with 54 additions and 71 deletions

View File

@ -144,7 +144,7 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_even
pub async fn create(
db: &SqlitePool,
name: String,
name: &str,
planned_amount_cox: i32,
trip_details: TripDetails,
) {
@ -165,7 +165,7 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_even
db: &SqlitePool,
planned_amount_cox: i32,
max_people: i32,
notes: Option<String>,
notes: Option<&str>,
) {
sqlx::query!(
"UPDATE planned_event SET planned_amount_cox = ? WHERE id = ?",

View File

@ -138,7 +138,7 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM trip WHERE i
cox: &CoxUser,
trip: &Trip,
max_people: i32,
notes: Option<String>,
notes: Option<&str>,
trip_type: Option<i64>, //TODO: Move to `TripType`
) -> Result<(), TripUpdateError> {
if !trip.is_trip_from_user(cox.id).await {

View File

@ -31,10 +31,10 @@ WHERE id like ?
/// Creates a new entry in `trip_details` and returns its id.
pub async fn create(
db: &SqlitePool,
planned_starting_time: String,
planned_starting_time: &str,
max_people: i32,
day: String,
notes: Option<String>,
day: &str,
notes: Option<&str>,
allow_guests: bool,
trip_type_id: Option<i64>,
) -> i64 {

View File

@ -49,7 +49,7 @@ WHERE id like ?
.ok()
}
pub async fn find_by_name(db: &SqlitePool, name: String) -> Option<Self> {
pub async fn find_by_name(db: &SqlitePool, name: &str) -> Option<Self> {
sqlx::query_as!(
User,
"
@ -79,7 +79,7 @@ ORDER BY name
.unwrap() //TODO: fixme
}
pub async fn create(db: &SqlitePool, name: String, is_guest: bool) -> bool {
pub async fn create(db: &SqlitePool, name: &str, is_guest: bool) -> bool {
sqlx::query!(
"INSERT INTO USER(name, is_guest) VALUES (?,?)",
name,
@ -103,7 +103,7 @@ ORDER BY name
.unwrap(); //Okay, because we can only create a User of a valid id
}
pub async fn login(db: &SqlitePool, name: String, pw: String) -> Result<Self, LoginError> {
pub async fn login(db: &SqlitePool, name: &str, pw: &str) -> Result<Self, LoginError> {
let Some(user) = User::find_by_name(db, name).await else {
return Err(LoginError::InvalidAuthenticationCombo); // Username not found
};
@ -133,7 +133,7 @@ ORDER BY name
.unwrap(); //Okay, because we can only create a User of a valid id
}
pub async fn update_pw(&self, db: &SqlitePool, pw: String) {
pub async fn update_pw(&self, db: &SqlitePool, pw: &str) {
let pw = Self::get_hashed_pw(&pw);
sqlx::query!("UPDATE user SET pw = ? where id = ?", pw, self.id)
.execute(db)