be able to show total km of each rower
Some checks failed
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled

This commit is contained in:
2026-01-03 21:26:20 +01:00
parent 48e1ee0d4c
commit 2aa6def560
2 changed files with 28 additions and 15 deletions

View File

@@ -104,9 +104,11 @@ pub struct Stat {
impl Stat { impl Stat {
pub async fn guest(db: &SqlitePool, year: Option<i32>) -> Stat { pub async fn guest(db: &SqlitePool, year: Option<i32>) -> Stat {
let year = match year { let year = year.unwrap_or_else(|| chrono::Local::now().year());
Some(year) => year, let year_filter = if year == 0 {
None => chrono::Local::now().year(), String::new()
} else {
format!("AND l.arrival LIKE '{}-%'", year)
}; };
//TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server)
// proper guests // proper guests
@@ -121,7 +123,7 @@ LEFT JOIN (
FROM rower FROM rower
GROUP BY logbook_id GROUP BY logbook_id
) m ON l.id = m.logbook_id ) m ON l.id = m.logbook_id
WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND not b.external; WHERE l.distance_in_km IS NOT NULL {year_filter} AND not b.external;
" "
)) ))
.fetch_one(db) .fetch_one(db)
@@ -145,7 +147,7 @@ WHERE u.id NOT IN (
WHERE ro.name = 'Donau Linz' WHERE ro.name = 'Donau Linz'
) )
AND l.distance_in_km IS NOT NULL AND l.distance_in_km IS NOT NULL
AND l.arrival LIKE '{year}-%' {year_filter}
AND u.name != 'Externe Steuerperson'; AND u.name != 'Externe Steuerperson';
" "
)) ))
@@ -183,9 +185,11 @@ AND u.name != 'Externe Steuerperson';
} }
pub async fn people(db: &SqlitePool, year: Option<i32>) -> Vec<Stat> { pub async fn people(db: &SqlitePool, year: Option<i32>) -> Vec<Stat> {
let year = match year { let year = year.unwrap_or_else(|| chrono::Local::now().year());
Some(year) => year, let year_filter = if year == 0 {
None => chrono::Local::now().year(), String::new()
} else {
format!("AND l.arrival LIKE '{}-%'", year)
}; };
//TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server) //TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server)
sqlx::query(&format!( sqlx::query(&format!(
@@ -201,7 +205,7 @@ FROM (
) u ) u
INNER JOIN rower r ON u.id = r.rower_id INNER JOIN rower r ON u.id = r.rower_id
INNER JOIN logbook l ON r.logbook_id = l.id INNER JOIN logbook l ON r.logbook_id = l.id
WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND u.name != 'Externe Steuerperson' WHERE l.distance_in_km IS NOT NULL {year_filter} AND u.name != 'Externe Steuerperson'
GROUP BY u.name GROUP BY u.name
ORDER BY rowed_km DESC, u.name; ORDER BY rowed_km DESC, u.name;
" "

View File

@@ -83,6 +83,7 @@
var select = document.getElementById('yearSelect'); var select = document.getElementById('yearSelect');
var currentYear = new Date().getFullYear(); var currentYear = new Date().getFullYear();
var selectedYear = getYearFromURL() || currentYear; var selectedYear = getYearFromURL() || currentYear;
for (var year = 1977; year <= currentYear; year++) { for (var year = 1977; year <= currentYear; year++) {
var option = document.createElement('option'); var option = document.createElement('option');
option.value = option.textContent = year; option.value = option.textContent = year;
@@ -91,6 +92,14 @@
} }
select.appendChild(option); select.appendChild(option);
} }
var gesamtOption = document.createElement('option');
gesamtOption.value = 0;
gesamtOption.textContent = 'GESAMT';
if (selectedYear == 0) {
gesamtOption.selected = true;
}
select.appendChild(gesamtOption);
} }
function changeYear() { function changeYear() {