Compare commits
No commits in common. "5cfaf44a7967bdc1cb93789eea61c73b2d2d473b" and "251c83eb300c698e6e1e7e633aa056884f9b7a1e" have entirely different histories.
5cfaf44a79
...
251c83eb30
@ -66,9 +66,7 @@ SELECT CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km
|
|||||||
FROM user u
|
FROM user 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
|
||||||
INNER JOIN user_role ur ON u.id = ur.user_id
|
WHERE u.is_guest = 1 AND l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%';
|
||||||
INNER JOIN role ro ON ur.role_id = ro.id
|
|
||||||
WHERE ro.name = 'scheckbuch' AND l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%';
|
|
||||||
"
|
"
|
||||||
))
|
))
|
||||||
.fetch_one(db)
|
.fetch_one(db)
|
||||||
@ -91,17 +89,10 @@ WHERE ro.name = 'scheckbuch' AND l.distance_in_km IS NOT NULL AND l.arrival LIKE
|
|||||||
sqlx::query(&format!(
|
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
|
||||||
FROM (
|
FROM user u
|
||||||
SELECT * FROM user
|
|
||||||
WHERE id NOT IN (
|
|
||||||
SELECT user_id FROM user_role
|
|
||||||
JOIN role ON user_role.role_id = role.id
|
|
||||||
WHERE role.name = 'scheckbuch'
|
|
||||||
)
|
|
||||||
) 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}-%'
|
WHERE u.is_guest = 0 AND l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%'
|
||||||
GROUP BY u.name
|
GROUP BY u.name
|
||||||
ORDER BY rowed_km DESC;
|
ORDER BY rowed_km DESC;
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user