Reviewed-on: #697
This commit is contained in:
@ -142,6 +142,7 @@ pub enum LogbookUpdateError {
|
||||
TooFast(i64, i64),
|
||||
AlreadyFinalized,
|
||||
ExternalSteeringPersonMustSteerOrShipmaster,
|
||||
BoatAlreadyOnWater,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -196,6 +197,7 @@ impl From<LogbookUpdateError> for LogbookCreateError {
|
||||
LogbookUpdateError::ExternalSteeringPersonMustSteerOrShipmaster => {
|
||||
LogbookCreateError::ExternalSteeringPersonMustSteerOrShipmaster
|
||||
}
|
||||
LogbookUpdateError::BoatAlreadyOnWater => LogbookCreateError::BoatAlreadyOnWater,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -573,6 +575,12 @@ ORDER BY departure DESC
|
||||
return Err(LogbookUpdateError::ArrivalNotAfterDeparture);
|
||||
}
|
||||
|
||||
if !boat.external {
|
||||
if boat.on_water_between(db, dep, arr).await {
|
||||
return Err(LogbookUpdateError::BoatAlreadyOnWater);
|
||||
};
|
||||
}
|
||||
|
||||
let duration_in_mins = (arr.and_utc().timestamp() - dep.and_utc().timestamp()) / 60;
|
||||
// Not possible to row < 1 min / 500 m = < 2 min / km
|
||||
let possible_distance_km = duration_in_mins / 2;
|
||||
|
Reference in New Issue
Block a user