add light damage
This commit is contained in:
parent
d5033ccf44
commit
aba8bc7749
@ -79,6 +79,10 @@ impl Boat {
|
||||
sqlx::query!("SELECT * FROM boat_damage WHERE boat_id=? AND lock_boat=true AND user_id_verified is null", self.id).fetch_optional(db).await.unwrap().is_some()
|
||||
}
|
||||
|
||||
pub async fn has_minor_damage(&self, db: &SqlitePool) -> bool {
|
||||
sqlx::query!("SELECT * FROM boat_damage WHERE boat_id=? AND lock_boat=false AND user_id_verified is null", self.id).fetch_optional(db).await.unwrap().is_some()
|
||||
}
|
||||
|
||||
pub async fn on_water(&self, db: &SqlitePool) -> bool {
|
||||
sqlx::query!(
|
||||
"SELECT * FROM logbook WHERE boat_id=? AND arrival is null",
|
||||
@ -105,10 +109,13 @@ ORDER BY amount_seats DESC
|
||||
|
||||
let mut res = Vec::new();
|
||||
for boat in boats {
|
||||
let damage = match boat.is_locked(db).await {
|
||||
true => BoatDamage::Locked,
|
||||
false => BoatDamage::None,
|
||||
};
|
||||
let mut damage = BoatDamage::None;
|
||||
if boat.has_minor_damage(db).await {
|
||||
damage = BoatDamage::Light;
|
||||
}
|
||||
if boat.is_locked(db).await {
|
||||
damage = BoatDamage::Locked;
|
||||
}
|
||||
res.push(BoatWithDetails {
|
||||
damage,
|
||||
on_water: boat.on_water(db).await,
|
||||
|
Loading…
Reference in New Issue
Block a user