From e94fc7958081b02dc40b3d822367a69a1e758dd0 Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 9 Mar 2024 17:02:50 +0100 Subject: [PATCH 1/2] deployed :-) --- staging-diff.sql | 9 --------- 1 file changed, 9 deletions(-) diff --git a/staging-diff.sql b/staging-diff.sql index fe85d50..e69de29 100644 --- a/staging-diff.sql +++ b/staging-diff.sql @@ -1,9 +0,0 @@ -CREATE TABLE IF NOT EXISTS "boathouse" ( - "id" INTEGER PRIMARY KEY AUTOINCREMENT, - "boat_id" INTEGER NOT NULL REFERENCES boat(id), - "aisle" TEXT NOT NULL CHECK (aisle in ('water', 'middle', 'mountain')), - "side" TEXT NOT NULL CHECK(side IN ('mountain', 'water')), - "level" INTEGER NOT NULL CHECK(level BETWEEN 0 AND 3), - CONSTRAINT unq UNIQUE (aisle, side, level) -- only 1 boat allowed to rest at each space -); - From 09e11dbb2b0df9c573f5ecf4758e809c5dbfc7fa Mon Sep 17 00:00:00 2001 From: philipp Date: Sat, 9 Mar 2024 18:16:32 +0100 Subject: [PATCH 2/2] show two rowes of boats for the 3 most left 'aisles' --- src/model/boathouse.rs | 46 ++++++++++++++++++++++++----- templates/board/boathouse.html.tera | 23 +++++++++++++-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/model/boathouse.rs b/src/model/boathouse.rs index a3ae022..0e96caf 100644 --- a/src/model/boathouse.rs +++ b/src/model/boathouse.rs @@ -17,22 +17,52 @@ pub struct Boathouse { } impl Boathouse { - pub async fn get(db: &SqlitePool) -> HashMap<&str, HashMap<&str, [Option<(i64, Boat)>; 4]>> { - let mut ret: HashMap<&str, HashMap<&str, [Option<(i64, Boat)>; 4]>> = HashMap::new(); + pub async fn get(db: &SqlitePool) -> HashMap<&str, HashMap<&str, [Option<(i64, Boat)>; 12]>> { + let mut ret: HashMap<&str, HashMap<&str, [Option<(i64, Boat)>; 12]>> = HashMap::new(); let mut mountain = HashMap::new(); - mountain.insert("mountain", [None, None, None, None]); - mountain.insert("water", [None, None, None, None]); + mountain.insert( + "mountain", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); + mountain.insert( + "water", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); ret.insert("mountain-aisle", mountain); let mut middle = HashMap::new(); - middle.insert("mountain", [None, None, None, None]); - middle.insert("water", [None, None, None, None]); + middle.insert( + "mountain", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); + middle.insert( + "water", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); ret.insert("middle-aisle", middle); let mut water = HashMap::new(); - water.insert("mountain", [None, None, None, None]); - water.insert("water", [None, None, None, None]); + water.insert( + "mountain", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); + water.insert( + "water", + [ + None, None, None, None, None, None, None, None, None, None, None, None, + ], + ); ret.insert("water-aisle", water); let boathouses = sqlx::query_as!( diff --git a/templates/board/boathouse.html.tera b/templates/board/boathouse.html.tera index c8e60b0..4edc2b6 100644 --- a/templates/board/boathouse.html.tera +++ b/templates/board/boathouse.html.tera @@ -7,7 +7,8 @@ {% set aisle = aisle_name ~ "-aisle" %} {% set place = boathouse[aisle][side_name] %} {% if place[level] %} - {{ place[level].1.name }} X + {{ place[level].1.name }} X {% elif boats | length > 0 %}
Kein Boot @@ -33,11 +34,29 @@ {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 1) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 2) }} {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 3) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 4) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 5) }} + {% set show_additional = false %} + {% if aisle_name == "mountain" %} + {% set show_additional = true %} + {% elif aisle_name == "middle" and side_name == "mountain" %} + {% set show_additional = true %} + {% endif %} + {% if show_additional %} +
+ {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 6) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 7) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 8) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 9) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 10) }} + {{ self::show_place(aisle_name = aisle_name, side_name = side_name, level = 11) }} + {% endif %} {% endmacro show_side %} {% macro show_aisle(name, last=false) %} -
+
{{ self::show_side(aisle_name = name, side_name = "mountain") }} {{ self::show_side(aisle_name = name, side_name = "water") }}