add todo
This commit is contained in:
parent
2dc70fa629
commit
290e05dc4c
@ -1,5 +1,5 @@
|
||||
use serde::Serialize;
|
||||
use sqlx::{Row, FromRow, SqlitePool};
|
||||
use sqlx::{FromRow, Row, SqlitePool};
|
||||
|
||||
#[derive(FromRow, Serialize, Clone)]
|
||||
pub struct Stat {
|
||||
@ -9,6 +9,7 @@ pub struct Stat {
|
||||
|
||||
impl Stat {
|
||||
pub async fn get_rowed_km(db: &SqlitePool) -> Vec<Stat> {
|
||||
//TODO: switch to query! macro again (once upgraded to sqlite 3.42 on server)
|
||||
sqlx::query(
|
||||
"SELECT u.name AS name, COALESCE(SUM(distance_in_km), 0) as rowed_km
|
||||
FROM user u
|
||||
@ -20,7 +21,7 @@ impl Stat {
|
||||
FROM logbook l
|
||||
INNER JOIN rower r ON r.logbook_id = l.id
|
||||
) AS subquery ON u.id = subquery.user_id
|
||||
GROUP BY u.id ORDER BY rowed_km DESC;"
|
||||
GROUP BY u.id ORDER BY rowed_km DESC;",
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
|
Loading…
Reference in New Issue
Block a user