From 075b657f65b00b3a79568371c111b5c842e50351 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Mon, 27 Feb 2023 14:31:01 +0100 Subject: [PATCH] Update --- bvplan/src/cache.rs | 7 +++---- bvplan/src/worker/get_substitutions.rs | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bvplan/src/cache.rs b/bvplan/src/cache.rs index a752608..42693ec 100644 --- a/bvplan/src/cache.rs +++ b/bvplan/src/cache.rs @@ -31,7 +31,6 @@ pub mod keys { pub const SUBSTITUTIONS_HTML: &str = "substs_html"; pub mod substitutions { - use chrono::prelude::*; use serde::{Deserialize, Serialize}; use super::*; @@ -59,13 +58,13 @@ pub mod keys { #[derive(Deserialize, Serialize, Debug)] pub struct SubstitutionQuery { #[serde(rename = "d")] - pub date: NaiveDate, + pub date: String, #[serde(rename = "w")] pub week_type: db::models::WeekType, #[serde(rename = "q")] - pub queried_at: NaiveDateTime, + pub queried_at: String, #[serde(rename = "i")] - pub last_import_time: NaiveDateTime, + pub last_import_time: String, #[serde(rename = "y")] pub schoolyear: String, #[serde(rename = "t")] diff --git a/bvplan/src/worker/get_substitutions.rs b/bvplan/src/worker/get_substitutions.rs index 823fc9d..f51ed2f 100644 --- a/bvplan/src/worker/get_substitutions.rs +++ b/bvplan/src/worker/get_substitutions.rs @@ -288,10 +288,22 @@ fn cache_substitutions( .load::(db_conn)?; let query = cache::keys::substitutions::SubstitutionQuery { - date, + date: format!( + "{} {}", + date.format("%d.%m.%Y"), + match date.weekday() { + chrono::Weekday::Mon => "Montag", + chrono::Weekday::Tue => "Dienstag", + chrono::Weekday::Wed => "Mittwoch", + chrono::Weekday::Thu => "Donnerstag", + chrono::Weekday::Fri => "Freitag", + chrono::Weekday::Sat => "Samstag", + chrono::Weekday::Sun => "Sonntag", + } + ), week_type, - queried_at, - last_import_time, + queried_at: queried_at.format("%d.%m.%Y %R").to_string(), + last_import_time: last_import_time.format("%d.%m.%Y %R").to_string(), schoolyear: "schoolyear".to_string(), tenant: "OHG Furtwangen".to_string(), substitutions: db::schema::substitutions::table