show-full-stats #1172
@@ -104,9 +104,11 @@ pub struct Stat {
|
||||
|
||||
impl Stat {
|
||||
pub async fn guest(db: &SqlitePool, year: Option<i32>) -> Stat {
|
||||
let year = match year {
|
||||
Some(year) => year,
|
||||
None => chrono::Local::now().year(),
|
||||
let year = year.unwrap_or_else(|| chrono::Local::now().year());
|
||||
let year_filter = if year == 0 {
|
||||
String::new()
|
||||
} else {
|
||||
format!("AND l.arrival LIKE '{}-%'", year)
|
||||
};
|
||||
//TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server)
|
||||
// proper guests
|
||||
@@ -121,7 +123,7 @@ LEFT JOIN (
|
||||
FROM rower
|
||||
GROUP BY 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)
|
||||
@@ -145,7 +147,7 @@ WHERE u.id NOT IN (
|
||||
WHERE ro.name = 'Donau Linz'
|
||||
)
|
||||
AND l.distance_in_km IS NOT NULL
|
||||
AND l.arrival LIKE '{year}-%'
|
||||
{year_filter}
|
||||
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> {
|
||||
let year = match year {
|
||||
Some(year) => year,
|
||||
None => chrono::Local::now().year(),
|
||||
let year = year.unwrap_or_else(|| chrono::Local::now().year());
|
||||
let year_filter = if year == 0 {
|
||||
String::new()
|
||||
} else {
|
||||
format!("AND l.arrival LIKE '{}-%'", year)
|
||||
};
|
||||
//TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server)
|
||||
sqlx::query(&format!(
|
||||
@@ -201,7 +205,7 @@ FROM (
|
||||
) u
|
||||
INNER JOIN rower r ON u.id = r.rower_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
|
||||
ORDER BY rowed_km DESC, u.name;
|
||||
"
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
var select = document.getElementById('yearSelect');
|
||||
var currentYear = new Date().getFullYear();
|
||||
var selectedYear = getYearFromURL() || currentYear;
|
||||
|
||||
for (var year = 1977; year <= currentYear; year++) {
|
||||
var option = document.createElement('option');
|
||||
option.value = option.textContent = year;
|
||||
@@ -91,6 +92,14 @@
|
||||
}
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user