Compare commits

...

2 Commits

Author SHA1 Message Date
251c83eb30 Merge pull request 'show guests km' (#147) from show-guests-km into main
Some checks failed
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Has been cancelled
Reviewed-on: #147
2024-01-05 20:09:59 +01:00
0aeec175ac show guests km
All checks were successful
CI/CD Pipeline / test (push) Successful in 15m30s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped
2024-01-05 20:08:13 +01:00

View File

@ -58,11 +58,25 @@ WHERE l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%' AND b.name != '
.fetch_one(db) .fetch_one(db)
.await .await
.unwrap() .unwrap()
.get::<i64, usize>(0); .get::<i64, usize>(0) as i32;
let rowed_km_guests = sqlx::query(&format!(
"
SELECT CAST(SUM(l.distance_in_km) AS INTEGER) AS rowed_km
FROM user u
INNER JOIN rower r ON u.id = r.rower_id
INNER JOIN logbook l ON r.logbook_id = l.id
WHERE u.is_guest = 1 AND l.distance_in_km IS NOT NULL AND l.arrival LIKE '{year}-%';
"
))
.fetch_one(db)
.await
.unwrap()
.get::<i64, usize>(0) as i32;
Stat { Stat {
name: "Gäste".into(), name: "Gäste".into(),
rowed_km: rowed_km as i32, rowed_km: rowed_km + rowed_km_guests,
} }
} }