add stats

This commit is contained in:
2023-07-24 20:56:46 +02:00
parent e90e27fc3d
commit 082fac9789
11 changed files with 142 additions and 9 deletions

View File

@ -98,6 +98,7 @@ struct LogHomeForm {
distance_in_km: i64,
comments: Option<String>,
logtype: Option<i64>,
rower: Vec<i64>,
}
#[post("/<logbook_id>", data = "<data>")]
@ -123,6 +124,7 @@ async fn home(
data.distance_in_km,
data.comments.clone(), //TODO: fixme
data.logtype,
data.rower.clone(), //TODO: fixme
)
.await
{

View File

@ -24,6 +24,7 @@ mod auth;
mod cox;
mod log;
mod misc;
mod stat;
#[get("/")]
async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
@ -116,6 +117,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
.mount("/", routes![index, join, remove])
.mount("/auth", auth::routes())
.mount("/log", log::routes())
.mount("/stat", stat::routes())
.mount("/cox", cox::routes())
.mount("/admin", admin::routes())
.mount("/", misc::routes())

19
src/tera/stat.rs Normal file
View File

@ -0,0 +1,19 @@
use rocket::{get, routes, Route, State};
use rocket_dyn_templates::{context, Template};
use sqlx::SqlitePool;
use crate::model::{stat::Stat, user::User};
#[get("/")]
async fn index(db: &State<SqlitePool>, user: User) -> Template {
let stat = Stat::get_rowed_km(db).await;
Template::render("stat", context!(loggedin_user: &user, stat))
}
pub fn routes() -> Vec<Route> {
routes![index]
}
#[cfg(test)]
mod test {}