This commit is contained in:
philipp 2023-09-23 18:26:04 +02:00
parent 1f801b0436
commit 90155dbc0f
2 changed files with 14 additions and 14 deletions

View File

@ -46,7 +46,7 @@ pub struct LogToFinalize {
pub distance_in_km: i64, pub distance_in_km: i64,
pub comments: Option<String>, pub comments: Option<String>,
pub logtype: Option<i64>, pub logtype: Option<i64>,
pub rower: Vec<i64>, pub rowers: Vec<i64>,
} }
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
@ -271,10 +271,10 @@ ORDER BY departure DESC
let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap(); //ok let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap(); //ok
if log.rower.len() > boat.amount_seats as usize - 1 { if log.rowers.len() > boat.amount_seats as usize - 1 {
return Err(LogbookUpdateError::TooManyRowers( return Err(LogbookUpdateError::TooManyRowers(
boat.amount_seats as usize, boat.amount_seats as usize,
log.rower.len() + 1, log.rowers.len() + 1,
)); ));
} }
@ -296,7 +296,7 @@ ORDER BY departure DESC
self.remove_rowers(&mut tx).await; self.remove_rowers(&mut tx).await;
for rower in &log.rower { for rower in &log.rowers {
Rower::create(&mut tx, self.id, *rower) Rower::create(&mut tx, self.id, *rower)
.await .await
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?; .map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;
@ -384,7 +384,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: Vec::new(), rowers: Vec::new(),
}, },
) )
.await .await
@ -407,7 +407,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: Vec::new(), rowers: Vec::new(),
}, },
) )
.await; .await;
@ -431,7 +431,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: Vec::new(), rowers: Vec::new(),
}, },
) )
.await; .await;
@ -455,7 +455,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: Vec::new(), rowers: Vec::new(),
}, },
) )
.await; .await;
@ -479,7 +479,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: Vec::new(), rowers: Vec::new(),
}, },
) )
.await; .await;
@ -503,7 +503,7 @@ mod test {
distance_in_km: None, distance_in_km: None,
comments: None, comments: None,
logtype: None, logtype: None,
rower: vec![1], rowers: vec![1],
}, },
) )
.await; .await;
@ -542,7 +542,7 @@ mod test {
distance_in_km: 42, distance_in_km: 42,
comments: Some("Perfect water".into()), comments: Some("Perfect water".into()),
logtype: None, logtype: None,
rower: vec![], rowers: vec![],
}, },
) )
.await .await
@ -565,7 +565,7 @@ mod test {
distance_in_km: 42, distance_in_km: 42,
comments: Some("Perfect water".into()), comments: Some("Perfect water".into()),
logtype: None, logtype: None,
rower: vec![], rowers: vec![],
}, },
) )
.await; .await;
@ -589,7 +589,7 @@ mod test {
distance_in_km: 42, distance_in_km: 42,
comments: Some("Perfect water".into()), comments: Some("Perfect water".into()),
logtype: None, logtype: None,
rower: vec![1], rowers: vec![1],
}, },
) )
.await; .await;

View File

@ -494,7 +494,7 @@ mod test {
fn test_cox() { fn test_cox() {
let pool = testdb!(); let pool = testdb!();
let res = User::cox(&pool).await; let res = User::cox(&pool).await;
assert_eq!(res.len(), 2); assert_eq!(res.len(), 3);
} }
#[sqlx::test] #[sqlx::test]