From 1bff81481155b09415cb47c48cc8ad9d8e1d6043 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 30 Jul 2023 22:59:47 +0200 Subject: [PATCH] push --- src/model/user.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/model/user.rs b/src/model/user.rs index 71ea728..9182679 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -95,7 +95,7 @@ WHERE name like ? } pub async fn on_water(&self, db: &SqlitePool) -> bool { - sqlx::query!( + if sqlx::query!( "SELECT * FROM logbook WHERE shipmaster=? AND arrival is null", self.id ) @@ -103,6 +103,22 @@ WHERE name like ? .await .unwrap() .is_some() + { + return true; + } + if sqlx::query!( + "SELECT * FROM logbook JOIN rower ON rower.logbook_id=logbook.id WHERE rower_id=? AND arrival is null", + self.id + ) + .fetch_optional(db) + .await + .unwrap() + .is_some() + { + return true; + } + + false } pub async fn all(db: &SqlitePool) -> Vec {