From 8a4d98a90f48b3ce473197d8d48ed24216e3a8b7 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Fri, 3 Jan 2025 12:36:29 +0100 Subject: [PATCH 1/9] nicer mail text --- src/model/mail.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/mail.rs b/src/model/mail.rs index 2a07024..3d3794b 100644 --- a/src/model/mail.rs +++ b/src/model/mail.rs @@ -298,7 +298,7 @@ Dein Vereinsbeitrag für das aktuelle Jahr beträgt {}€", } if is_family { content.push_str(&format!( - "Dieser gilt für die gesamte Familie ({}).\n", + "Dieser gilt für die gesamte Familie ({}). Diese Mail wird an alle Familienmitglieder verschickt, bezahlen müsst ihr natürlich nur 1x.\n", fees.name )) } -- 2.47.1 From d3bb05053469050f1f6fcabc4df2a9c75fb15b1b Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Sat, 4 Jan 2025 10:56:32 +0100 Subject: [PATCH 2/9] fix count in statistic --- templates/stat.people.html.tera | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index 1431af0..3c8e361 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -39,21 +39,21 @@ {% endfor %}
Summe Vereinsmitglieder {{ club_km }} km
Summe {{ guest_km.name }} {{ guest_km.rowed_km }} km
Gesamtsumme -- 2.47.1 From 3232a03d75e90b0e8571fa873f202906888938f8 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Mon, 6 Jan 2025 13:14:19 +0100 Subject: [PATCH 3/9] show amount of trips in stat --- src/model/stat.rs | 45 ++++++++++++++++++++++++--------- src/tera/stat.rs | 3 ++- templates/stat.people.html.tera | 6 ++++- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/model/stat.rs b/src/model/stat.rs index dad5ca0..6ec6b16 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -98,6 +98,7 @@ ORDER BY #[derive(FromRow, Serialize, Clone)] pub struct Stat { name: String, + pub(crate) amount_trips: i32, pub(crate) rowed_km: i32, } @@ -108,9 +109,11 @@ impl Stat { None => chrono::Local::now().year(), }; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) - let rowed_km = sqlx::query(&format!( + // proper guests + let guests = sqlx::query(&format!( " -SELECT SUM((b.amount_seats - COALESCE(m.member_count, 0)) * l.distance_in_km) as total_guest_km +SELECT SUM((b.amount_seats - COALESCE(m.member_count, 0)) * l.distance_in_km) as total_guest_km, + SUM(b.amount_seats - COALESCE(m.member_count, 0)) AS amount_trips FROM logbook l JOIN boat b ON l.boat_id = b.id LEFT JOIN ( @@ -123,12 +126,15 @@ WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND not b.exter )) .fetch_one(db) .await - .unwrap() - .get::(0) as i32; + .unwrap(); - let rowed_km_guests = sqlx::query(&format!( + let guest_km: i32 = guests.get(0); + let guest_amount_trips: i32 = guests.get(1); + + // e.g. scheckbücher + let guest_user = sqlx::query(&format!( " -SELECT CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km +SELECT CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km, COUNT(*) AS amount_trips FROM user u INNER JOIN rower r ON u.id = r.rower_id INNER JOIN logbook l ON r.logbook_id = l.id @@ -145,15 +151,27 @@ AND u.name != 'Externe Steuerperson'; )) .fetch_one(db) .await - .unwrap() - .get::(0) as i32; + .unwrap(); + + let guest_user_km: i32 = guest_user.get(0); + let guest_user_amount_trips: i32 = guest_user.get(1); Stat { name: "Gäste".into(), - rowed_km: rowed_km + rowed_km_guests, + amount_trips: guest_amount_trips + guest_user_amount_trips, + rowed_km: guest_km + guest_user_km, } } + pub async fn trips_people(db: &SqlitePool, year: Option) -> i32 { + let stats = Self::people(db, year).await; + let mut sum = 0; + for stat in stats { + sum += stat.amount_trips; + } + + sum + } pub async fn sum_people(db: &SqlitePool, year: Option) -> i32 { let stats = Self::people(db, year).await; let mut sum = 0; @@ -172,7 +190,7 @@ AND u.name != 'Externe Steuerperson'; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) sqlx::query(&format!( " -SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km +SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km, COUNT(*) AS amount_trips FROM ( SELECT * FROM user WHERE id IN ( @@ -194,6 +212,7 @@ ORDER BY rowed_km DESC, u.name; .into_iter() .map(|row| Stat { name: row.get("name"), + amount_trips: row.get("amount_trips"), rowed_km: row.get("rowed_km"), }) .collect() @@ -203,7 +222,7 @@ ORDER BY rowed_km DESC, u.name; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) let row = sqlx::query(&format!( " -SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km +SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km, COUNT(*) AS amount_trips FROM ( SELECT * FROM user WHERE id={} @@ -220,6 +239,7 @@ WHERE l.distance_in_km IS NOT NULL; Stat { name: row.get("name"), + amount_trips: row.get("amount_trips"), rowed_km: row.get("rowed_km"), } } @@ -232,7 +252,7 @@ WHERE l.distance_in_km IS NOT NULL; //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) let row = sqlx::query(&format!( " -SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km +SELECT u.name, CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km, COUNT(*) AS amount_trips FROM ( SELECT * FROM user WHERE id={} @@ -249,6 +269,7 @@ WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%'; Stat { name: row.get("name"), + amount_trips: row.get("amount_trips"), rowed_km: row.get("rowed_km"), } } diff --git a/src/tera/stat.rs b/src/tera/stat.rs index 5c7217c..f1823bf 100644 --- a/src/tera/stat.rs +++ b/src/tera/stat.rs @@ -32,13 +32,14 @@ async fn index_boat_kiosk(db: &State, _kiosk: KioskCookie) -> Templa async fn index(db: &State, user: DonauLinzUser, year: Option) -> Template { let stat = Stat::people(db, year).await; let club_km = Stat::sum_people(db, year).await; + let club_trips = Stat::trips_people(db, year).await; let guest_km = Stat::guest(db, year).await; let personal = stat::get_personal(db, &user).await; let kiosk = false; Template::render( "stat.people", - context!(loggedin_user: &UserWithDetails::from_user(user.into_inner(), db).await, stat, personal, kiosk, guest_km, club_km), + context!(loggedin_user: &UserWithDetails::from_user(user.into_inner(), db).await, stat, personal, kiosk, guest_km, club_km, club_trips), ) } diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index 3c8e361..9856dd6 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -20,7 +20,7 @@
- {% set_global km = 0 %} {% set_global index = 1 %} + {% set_global km = 0 %} {% set_global km = 0 %} {% set_global index = 1 %} {% for s in stat %}
{{ s.name }} {{ s.rowed_km }} km + {{ s.amount_trips }} Fahrt{{ s.amount_trips | pluralize(plural="en") }} {% set_global km = s.rowed_km %}
{% endfor %} @@ -44,6 +45,7 @@ Summe Vereinsmitglieder {{ club_km }} km + {{ club_trips }} Fahrt{{ club_trips | pluralize(plural="en") }}
Summe {{ guest_km.name }} {{ guest_km.rowed_km }} km + {{ guest_km.amount_trips }} Fahrt{{ guest_km.amount_trips | pluralize(plural="en") }}
Gesamtsumme {{ club_km + guest_km.rowed_km }} km + {{ guest_km.amount_trips + club_trips }} Fahrt{{ guest_km.amount_trips + club_trips | pluralize(plural="en") }}
-- 2.47.1 From 022ec6bd5bf5885e25c372dce1ca54b5b56aae6f Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Tue, 7 Jan 2025 10:52:46 +0100 Subject: [PATCH 4/9] [TASK] make stats more beautiful --- templates/stat.people.html.tera | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index 9856dd6..dee4e08 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -20,6 +20,14 @@
+
+ # + Name + km + Fahrten +
{% set_global km = 0 %} {% set_global km = 0 %} {% set_global index = 1 %} {% for s in stat %}
{{ s.name }} - {{ s.rowed_km }} km - {{ s.amount_trips }} Fahrt{{ s.amount_trips | pluralize(plural="en") }} + {{ s.rowed_km }} + {{ s.amount_trips }} {% set_global km = s.rowed_km %}
{% endfor %} -
Summe Vereinsmitglieder - {{ club_km }} km - {{ club_trips }} Fahrt{{ club_trips | pluralize(plural="en") }} + {{ club_km }} + {{ club_trips }}
Summe {{ guest_km.name }} - {{ guest_km.rowed_km }} km - {{ guest_km.amount_trips }} Fahrt{{ guest_km.amount_trips | pluralize(plural="en") }} + {{ guest_km.rowed_km }} + {{ guest_km.amount_trips }}
Gesamtsumme - {{ club_km + guest_km.rowed_km }} km - {{ guest_km.amount_trips + club_trips }} Fahrt{{ guest_km.amount_trips + club_trips | pluralize(plural="en") }} + {{ club_km + guest_km.rowed_km }} + {{ guest_km.amount_trips + club_trips }}
-- 2.47.1 From 5b013fe389923b41660a446c0ee8f0a8842fe7c6 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Tue, 7 Jan 2025 10:54:15 +0100 Subject: [PATCH 5/9] [TASK] rm unnecessary personal stat --- templates/stat.people.html.tera | 39 +-------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index dee4e08..fbc5284 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -72,42 +72,5 @@ {{ guest_km.amount_trips + club_trips }} -
- - -{% endblock content %} + \ No newline at end of file -- 2.47.1 From 6237340f722663a39aa1aa6dd7fb0c1490d83592 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Tue, 7 Jan 2025 11:39:36 +0100 Subject: [PATCH 6/9] fix ci --- templates/stat.people.html.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index fbc5284..de4430a 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -73,4 +73,4 @@ - \ No newline at end of file +{% endblock content %} -- 2.47.1 From 0ebcd5a284d3d60c3d2cc3d11687ca1504abadd2 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Tue, 7 Jan 2025 11:44:56 +0100 Subject: [PATCH 7/9] allow changing the year in stats again --- templates/stat.people.html.tera | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index de4430a..cc02d1d 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -73,4 +73,31 @@ + {% endblock content %} -- 2.47.1 From be4f302a4c123e394b79e061d40707907328e048 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Tue, 7 Jan 2025 14:07:52 +0100 Subject: [PATCH 8/9] [TASK] make stats more beautiful --- templates/stat.people.html.tera | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/stat.people.html.tera b/templates/stat.people.html.tera index cc02d1d..ce947a7 100644 --- a/templates/stat.people.html.tera +++ b/templates/stat.people.html.tera @@ -25,7 +25,7 @@ data-filter="Header"> # Name - km + km Fahrten {% set_global km = 0 %} {% set_global km = 0 %} {% set_global index = 1 %} @@ -42,7 +42,7 @@ {% endif %} {{ s.name }} - {{ s.rowed_km }} + {{ s.rowed_km }} {{ s.amount_trips }} {% set_global km = s.rowed_km %} @@ -52,7 +52,7 @@ data-filter="Summe Vereinsmitglieder"> Summe Vereinsmitglieder - {{ club_km }} + {{ club_km }} {{ club_trips }}
Summe {{ guest_km.name }} - {{ guest_km.rowed_km }} + {{ guest_km.rowed_km }} {{ guest_km.amount_trips }}
Gesamtsumme - {{ club_km + guest_km.rowed_km }} + {{ club_km + guest_km.rowed_km }} {{ guest_km.amount_trips + club_trips }}
-- 2.47.1 From af4163a065fc5a67f392aa6e447e1a7532207afb Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Thu, 9 Jan 2025 10:21:44 +0100 Subject: [PATCH 9/9] add confirm dialog before creating a new user --- templates/admin/user/index.html.tera | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/admin/user/index.html.tera b/templates/admin/user/index.html.tera index da383ec..c50e64f 100644 --- a/templates/admin/user/index.html.tera +++ b/templates/admin/user/index.html.tera @@ -5,6 +5,7 @@

Users

{% if allowed_to_edit %}
-- 2.47.1