|
|
|
@ -26,6 +26,7 @@ pub struct Boat {
|
|
|
|
|
skull: bool,
|
|
|
|
|
#[serde(default = "bool::default")]
|
|
|
|
|
external: bool,
|
|
|
|
|
pub deleted: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
@ -188,8 +189,9 @@ AND date('now') BETWEEN start_date AND end_date;",
|
|
|
|
|
let boats = sqlx::query_as!(
|
|
|
|
|
Boat,
|
|
|
|
|
"
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
|
|
|
|
FROM boat
|
|
|
|
|
WHERE deleted=false
|
|
|
|
|
ORDER BY amount_seats DESC
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
@ -215,12 +217,14 @@ SELECT
|
|
|
|
|
b.default_shipmaster_only_steering,
|
|
|
|
|
b.default_destination,
|
|
|
|
|
b.skull,
|
|
|
|
|
b.external
|
|
|
|
|
b.external,
|
|
|
|
|
b.deleted
|
|
|
|
|
FROM
|
|
|
|
|
boat AS b
|
|
|
|
|
WHERE
|
|
|
|
|
b.external = false
|
|
|
|
|
AND b.location_id = (SELECT id FROM location WHERE name = 'Linz')
|
|
|
|
|
AND b.deleted = false
|
|
|
|
|
ORDER BY
|
|
|
|
|
b.name DESC;
|
|
|
|
|
"
|
|
|
|
@ -240,7 +244,7 @@ ORDER BY
|
|
|
|
|
sqlx::query_as!(
|
|
|
|
|
Boat,
|
|
|
|
|
"
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
|
|
|
|
FROM boat
|
|
|
|
|
WHERE owner is null or owner = ?
|
|
|
|
|
ORDER BY amount_seats DESC
|
|
|
|
@ -254,7 +258,7 @@ ORDER BY amount_seats DESC
|
|
|
|
|
sqlx::query_as!(
|
|
|
|
|
Boat,
|
|
|
|
|
"
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
|
|
|
|
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
|
|
|
|
FROM boat
|
|
|
|
|
WHERE owner = ? OR (owner is null and amount_seats = 1)
|
|
|
|
|
ORDER BY amount_seats DESC
|
|
|
|
@ -272,7 +276,7 @@ ORDER BY amount_seats DESC
|
|
|
|
|
.unwrap();
|
|
|
|
|
let boats_in_ottensheim = sqlx::query_as!(
|
|
|
|
|
Boat,
|
|
|
|
|
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
|
|
|
|
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
|
|
|
|
FROM boat
|
|
|
|
|
WHERE owner is null and location_id = ?
|
|
|
|
|
ORDER BY amount_seats DESC
|
|
|
|
@ -291,7 +295,7 @@ ORDER BY amount_seats DESC
|
|
|
|
|
let boats = sqlx::query_as!(
|
|
|
|
|
Boat,
|
|
|
|
|
"
|
|
|
|
|
SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external
|
|
|
|
|
SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted
|
|
|
|
|
FROM boat
|
|
|
|
|
INNER JOIN location ON boat.location_id = location.id
|
|
|
|
|
WHERE location.name=?
|
|
|
|
@ -354,7 +358,7 @@ ORDER BY amount_seats DESC
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn delete(&self, db: &SqlitePool) {
|
|
|
|
|
sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
|
|
|
|
|
sqlx::query!("UPDATE boat SET deleted=1 WHERE id=?", self.id)
|
|
|
|
|
.execute(db)
|
|
|
|
|
.await
|
|
|
|
|
.unwrap(); //Okay, because we can only create a Boat of a valid id
|
|
|
|
|