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 comments: Option<String>,
pub logtype: Option<i64>,
pub rower: Vec<i64>,
pub rowers: Vec<i64>,
}
#[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
if log.rower.len() > boat.amount_seats as usize - 1 {
if log.rowers.len() > boat.amount_seats as usize - 1 {
return Err(LogbookUpdateError::TooManyRowers(
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;
for rower in &log.rower {
for rower in &log.rowers {
Rower::create(&mut tx, self.id, *rower)
.await
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;
@ -384,7 +384,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: Vec::new(),
rowers: Vec::new(),
},
)
.await
@ -407,7 +407,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: Vec::new(),
rowers: Vec::new(),
},
)
.await;
@ -431,7 +431,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: Vec::new(),
rowers: Vec::new(),
},
)
.await;
@ -455,7 +455,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: Vec::new(),
rowers: Vec::new(),
},
)
.await;
@ -479,7 +479,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: Vec::new(),
rowers: Vec::new(),
},
)
.await;
@ -503,7 +503,7 @@ mod test {
distance_in_km: None,
comments: None,
logtype: None,
rower: vec![1],
rowers: vec![1],
},
)
.await;
@ -542,7 +542,7 @@ mod test {
distance_in_km: 42,
comments: Some("Perfect water".into()),
logtype: None,
rower: vec![],
rowers: vec![],
},
)
.await
@ -565,7 +565,7 @@ mod test {
distance_in_km: 42,
comments: Some("Perfect water".into()),
logtype: None,
rower: vec![],
rowers: vec![],
},
)
.await;
@ -589,7 +589,7 @@ mod test {
distance_in_km: 42,
comments: Some("Perfect water".into()),
logtype: None,
rower: vec![1],
rowers: vec![1],
},
)
.await;

View File

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