This commit is contained in:
Dominic Grimm 2023-02-27 14:31:01 +01:00
parent b25c20ab69
commit 075b657f65
No known key found for this signature in database
GPG key ID: 6F294212DEAAC530
2 changed files with 18 additions and 7 deletions

View file

@ -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")]

View file

@ -288,10 +288,22 @@ fn cache_substitutions(
.load::<StartEndTime>(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