diff --git a/src/model/trip.rs b/src/model/trip.rs index 5df6f0f..8adb67f 100644 --- a/src/model/trip.rs +++ b/src/model/trip.rs @@ -131,11 +131,8 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM trip WHERE i .fetch_one(db) .await .unwrap(); //TODO: fixme - let trip_details_id = match trip_details.id { - Some(id) => id, - None => { + let Some(trip_details_id) = trip_details.id else { return Err(TripUpdateError::TripDoesNotExist); - } }; sqlx::query!( @@ -152,14 +149,14 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM trip WHERE i } pub async fn delete_by_planned_event_id(db: &SqlitePool, user_id: i64, planned_event_id: i64) { - let _ = sqlx::query!( + sqlx::query!( "DELETE FROM trip WHERE cox_id = ? AND planned_event_id = ?", user_id, planned_event_id ) .execute(db) .await - .is_ok(); + .unwrap(); //TODO: fixme } pub(crate) async fn delete( diff --git a/src/model/user.rs b/src/model/user.rs index 8740f31..2f0bfeb 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -99,11 +99,8 @@ ORDER BY name } pub async fn login(db: &SqlitePool, name: String, pw: String) -> Result { - let user = match User::find_by_name(db, name).await { - Some(user) => user, - None => { - return Err(LoginError::InvalidAuthenticationCombo); // Username not found - } + let Some(user) = User::find_by_name(db, name).await else { + return Err(LoginError::InvalidAuthenticationCombo); // Username not found }; match user.pw.clone() { diff --git a/src/model/usertrip.rs b/src/model/usertrip.rs index 593cf9a..cefd669 100644 --- a/src/model/usertrip.rs +++ b/src/model/usertrip.rs @@ -10,7 +10,7 @@ impl UserTrip { user_id: i64, trip_details_id: i64, ) -> Result<(), UserTripError> { - let trip_details = TripDetails::find_by_id(&db, trip_details_id) + let trip_details = TripDetails::find_by_id(db, trip_details_id) .await .ok_or(UserTripError::TripDetailsNotFound)?;