boatshouse functionality, fixes #183
This commit is contained in:
@ -181,6 +181,41 @@ ORDER BY amount_seats DESC
|
||||
Self::boats_to_details(db, boats).await
|
||||
}
|
||||
|
||||
pub async fn all_for_boatshouse(db: &SqlitePool) -> Vec<BoatWithDetails> {
|
||||
let boats = sqlx::query_as!(
|
||||
Boat,
|
||||
"
|
||||
SELECT
|
||||
b.id,
|
||||
b.name,
|
||||
b.amount_seats,
|
||||
b.location_id,
|
||||
b.owner,
|
||||
b.year_built,
|
||||
b.boatbuilder,
|
||||
b.default_shipmaster_only_steering,
|
||||
b.default_destination,
|
||||
b.skull,
|
||||
b.external
|
||||
FROM
|
||||
boat AS b
|
||||
LEFT JOIN
|
||||
boathouse AS bh ON b.id = bh.boat_id
|
||||
WHERE
|
||||
b.external = false
|
||||
AND b.location_id = (SELECT id FROM location WHERE name = 'Linz')
|
||||
AND bh.id IS NULL -- This ensures the boat does not have an entry in the boathouse table
|
||||
ORDER BY
|
||||
b.name DESC;
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
|
||||
Self::boats_to_details(db, boats).await
|
||||
}
|
||||
|
||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<BoatWithDetails> {
|
||||
if user.has_role(db, "admin").await {
|
||||
return Self::all(db).await;
|
||||
|
Reference in New Issue
Block a user