diff --git a/src/model/stat.rs b/src/model/stat.rs index c1dee56..5a167e3 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -1,5 +1,5 @@ use serde::Serialize; -use sqlx::{FromRow, SqlitePool}; +use sqlx::{Row, FromRow, SqlitePool}; #[derive(FromRow, Serialize, Clone)] pub struct Stat { @@ -9,7 +9,7 @@ pub struct Stat { impl Stat { pub async fn get_rowed_km(db: &SqlitePool) -> Vec { - sqlx::query!( + sqlx::query( "SELECT u.name AS name, COALESCE(SUM(distance_in_km), 0) as rowed_km FROM user u INNER JOIN ( @@ -27,8 +27,8 @@ impl Stat { .unwrap() .into_iter() .map(|row| Stat { - name: row.name, - rowed_km: row.rowed_km.unwrap_or(0), + name: row.get("name"), + rowed_km: row.get("rowed_km"), }) .collect() }