25 lines
543 B
Rust
Raw Normal View History

2023-07-24 20:56:46 +02:00
use rocket::{get, routes, Route, State};
use rocket_dyn_templates::{context, Template};
use sqlx::SqlitePool;
2023-10-01 14:35:04 +02:00
use crate::model::{
stat::{self, Stat},
user::User,
};
2023-07-24 20:56:46 +02:00
#[get("/")]
async fn index(db: &State<SqlitePool>, user: User) -> Template {
let stat = Stat::get_rowed_km(db).await;
2023-10-01 14:35:04 +02:00
let personal = stat::get_personal(db, &user).await;
2023-07-24 20:56:46 +02:00
2023-10-01 18:14:05 +02:00
println!("{personal:?}");
2023-10-01 14:35:04 +02:00
Template::render("stat", context!(loggedin_user: &user, stat, personal))
2023-07-24 20:56:46 +02:00
}
pub fn routes() -> Vec<Route> {
routes![index]
}
#[cfg(test)]
mod test {}