staging #345

Merged
philipp merged 2 commits from staging into main 2024-04-06 20:00:27 +02:00
Showing only changes of commit b3041d9ca7 - Show all commits

View File

@ -27,23 +27,23 @@ impl BoatStat {
let rows = sqlx::query(
"
SELECT
boat.id,
location.name AS location,
CAST(strftime('%Y', arrival) AS INTEGER) AS year,
CAST(SUM(distance_in_km) AS INTEGER) AS rowed_km
FROM
logbook
INNER JOIN
boat ON boat.id = logbook.boat_id
INNER JOIN
location ON boat.location_id = location.id
WHERE
boat.name != 'Externes Boot'
GROUP BY
boat_id, year
ORDER BY
boat.name, year DESC;
SELECT
boat.id,
location.name AS location,
CAST(strftime('%Y', COALESCE(arrival, 'now')) AS INTEGER) AS year,
CAST(SUM(COALESCE(distance_in_km, 0)) AS INTEGER) AS rowed_km
FROM
boat
LEFT JOIN
logbook ON boat.id = logbook.boat_id AND logbook.arrival IS NOT NULL
LEFT JOIN
location ON boat.location_id = location.id
WHERE
boat.name != 'Externes Boot'
GROUP BY
boat.id, year
ORDER BY
boat.name, year DESC;
",
)
.fetch_all(db)