From c34f2c1ac4d828bbb05b8bd0c180045f1ec283a3 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Sun, 13 Apr 2025 21:34:52 +0200 Subject: [PATCH] show which teams to take to first station; Fixes #29 --- README.md | 1 + src/admin/route/mod.rs | 3 ++- src/admin/team/mod.rs | 4 ++-- src/station.rs | 31 ++++++++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 129aa5a..6abea4d 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ ## Marketing - single-binary (+ db + .env) +- Teams werden automatisch (start)stationen zugewiesen diff --git a/src/admin/route/mod.rs b/src/admin/route/mod.rs index 3a6b1c5..6a2322e 100644 --- a/src/admin/route/mod.rs +++ b/src/admin/route/mod.rs @@ -130,9 +130,10 @@ DROP TABLE temp_pos;", } pub(crate) async fn stations(&self, db: &SqlitePool) -> Vec { + // TODO: switch to macro sqlx::query_as::<_, Station>( " - SELECT s.id, s.name, s.notes, s.amount_people, s.last_login, s.pw, s.lat, s.lng + SELECT s.id, s.name, s.notes, s.amount_people, s.last_login, s.pw, s.lat, s.lng, s.ready FROM station s JOIN route_station rs ON s.id = rs.station_id WHERE rs.route_id = ? diff --git a/src/admin/team/mod.rs b/src/admin/team/mod.rs index c6d6b12..242de07 100644 --- a/src/admin/team/mod.rs +++ b/src/admin/team/mod.rs @@ -13,8 +13,8 @@ mod web; pub(crate) struct Team { pub(crate) id: i64, pub(crate) name: String, - notes: Option, - amount_people: Option, + pub(crate) notes: Option, + pub(crate) amount_people: Option, first_station_id: i64, route_id: i64, } diff --git a/src/station.rs b/src/station.rs index 5b10f07..b453c85 100644 --- a/src/station.rs +++ b/src/station.rs @@ -40,7 +40,36 @@ async fn view( @if let (Some(lat), Some(lng)) = (station.lat, station.lng) { article { details open[(!station.ready)]{ - summary { "Stationsort" } + summary { "Infos" } + @let first_teams = Team::all_with_first_station(&db, &station).await; + @if first_teams.is_empty() { + "Du musst keine Teams zu deiner Station mitnehmen" + } @else{ + b { (format!("Nimm bitte folgende {} Teams am Anfang zu deiner Station mit:", first_teams.len())) } + ol { + @for team in first_teams { + li { + b { + (team.name) + } + ul { + @if let Some(amount_people) = team.amount_people { + li { + (amount_people) + " Personen" + } + } + @if let Some(notes) = team.notes { + li { + (notes) + } + } + } + + } + } + } + } b { "Hier befindet sich deine Station:" } div id="map" style="height: 500px" {} script { (format!("