Update dependencies

This commit is contained in:
2021-10-22 13:00:29 +02:00
parent 7698911078
commit e2649165a7
13 changed files with 539 additions and 420 deletions

View File

@ -4,10 +4,8 @@ use crate::status_json::StatusJson;
use crate::util::OrdL;
use chrono::{Date, DateTime, Datelike, Duration, Local, Timelike};
use itertools::Itertools;
use rocket::http::Status;
use rocket::{get, State};
use rocket_contrib::templates::Template;
use rocket_contrib::uuid::Uuid;
use rocket::{get, http::Status, response::content::Html, serde::uuid::Uuid, State};
use rocket_dyn_templates::Template;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap, HashSet};
@ -142,8 +140,8 @@ fn category_stats_ctx(
pub fn single_stats(
_auth: Authorized,
category_id: Uuid,
db: State<'_, sled::Db>,
) -> Result<Template, StatusJson> {
db: &State<sled::Db>,
) -> Result<Html<Template>, StatusJson> {
let categories_tree = db.open_tree(category::NAME)?;
let sessions_tree = db.open_tree(session::NAME)?;
@ -154,12 +152,12 @@ pub fn single_stats(
let sessions: HashMap<session::K, session::V> = session::get_all(&sessions_tree)?;
let now = Local::now();
let ctx = category_stats_ctx(now, *category_id, category, &sessions, &child_map);
Ok(Template::render("stats_single", dbg!(&ctx)))
let ctx = category_stats_ctx(now, category_id, category, &sessions, &child_map);
Ok(Html(Template::render("stats_single", dbg!(&ctx))))
}
#[get("/stats")]
pub fn all_stats(_auth: Authorized, db: State<'_, sled::Db>) -> Result<Template, StatusJson> {
pub fn all_stats(_auth: Authorized, db: &State<sled::Db>) -> Result<Html<Template>, StatusJson> {
#[derive(Debug, Serialize, Deserialize)]
struct StatsContext {
categories_stats: Vec<CategoryStatsCtx>,
@ -187,7 +185,7 @@ pub fn all_stats(_auth: Authorized, db: State<'_, sled::Db>) -> Result<Template,
let context = StatsContext { categories_stats };
Ok(Template::render("stats_all", &context))
Ok(Html(Template::render("stats_all", &context)))
}
/// Compute the duration of `day` that is covered by the span `start..end`