add stats
This commit is contained in:
@ -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
|
||||
{
|
||||
|
@ -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
19
src/tera/stat.rs
Normal 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 {}
|
Reference in New Issue
Block a user