Update
This commit is contained in:
parent
df22d46260
commit
438920ece6
5 changed files with 217 additions and 240 deletions
|
@ -48,9 +48,9 @@ pub mod keys {
|
|||
#[serde(rename = "t")]
|
||||
pub teachers: Option<Vec<String>>,
|
||||
#[serde(rename = "pr")]
|
||||
pub prev_room: Option<String>,
|
||||
pub prev_rooms: Vec<String>,
|
||||
#[serde(rename = "r")]
|
||||
pub room: Option<String>,
|
||||
pub rooms: Vec<String>,
|
||||
#[serde(rename = "tx")]
|
||||
pub text: Option<String>,
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::io::Write;
|
|||
use std::path::Path;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::vec;
|
||||
|
||||
use crate::cache;
|
||||
use crate::config;
|
||||
|
@ -84,7 +85,7 @@ async fn fetch_substitutions(
|
|||
schoolyear_id,
|
||||
date,
|
||||
week_type,
|
||||
queried_at: Utc::now().naive_utc(),
|
||||
queried_at: Local::now().naive_local(),
|
||||
})
|
||||
.returning(db::schema::substitution_queries::id)
|
||||
.get_result::<i64>(db_conn)?;
|
||||
|
@ -315,41 +316,33 @@ fn cache_substitutions(
|
|||
.order(db::schema::substitution_teachers::position.asc())
|
||||
.load::<db::models::SubstitutionTeacher>(db_conn)?;
|
||||
|
||||
let (prev_room, room) = if let Some(r) = db::schema::substitution_rooms::table
|
||||
.filter(db::schema::substitution_rooms::substitution_id.eq(s.id))
|
||||
.order(db::schema::substitution_rooms::position.asc())
|
||||
.first::<db::models::SubstitutionRoom>(db_conn)
|
||||
.optional()?
|
||||
{
|
||||
let name = if let Some(id) = r.room_id {
|
||||
Some(
|
||||
db::schema::rooms::table
|
||||
.select(db::schema::rooms::name)
|
||||
.filter(db::schema::rooms::id.eq(id))
|
||||
.first::<String>(db_conn)?,
|
||||
let (prev_rooms, rooms) = {
|
||||
let r: Vec<db::models::SubstitutionRoom> =
|
||||
db::schema::substitution_rooms::table
|
||||
.filter(db::schema::substitution_rooms::substitution_id.eq(s.id))
|
||||
.order(db::schema::substitution_rooms::position.asc())
|
||||
.load::<db::models::SubstitutionRoom>(db_conn)?;
|
||||
|
||||
let prev_rooms = db::schema::rooms::table
|
||||
.select(db::schema::rooms::name)
|
||||
.filter(
|
||||
db::schema::rooms::id
|
||||
.eq_any(r.iter().flat_map(|x| x.original_id).collect::<Vec<i32>>()),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.load::<String>(db_conn)?;
|
||||
|
||||
let rooms = db::schema::rooms::table
|
||||
.select(db::schema::rooms::name)
|
||||
.filter(
|
||||
db::schema::rooms::id
|
||||
.eq_any(r.iter().flat_map(|x| x.room_id).collect::<Vec<i32>>()),
|
||||
)
|
||||
.load::<String>(db_conn)?;
|
||||
|
||||
match s.subst_type {
|
||||
db::models::SubstitutionType::Cancel => (name, None),
|
||||
_ => (
|
||||
if let Some(id) = r.original_id {
|
||||
Some(
|
||||
db::schema::rooms::table
|
||||
.select(db::schema::rooms::name)
|
||||
.filter(db::schema::rooms::id.eq(id))
|
||||
.first::<String>(db_conn)?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
name,
|
||||
),
|
||||
db::models::SubstitutionType::Cancel => (rooms, vec![]),
|
||||
_ => (prev_rooms, rooms),
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
let (prev_subject, subject) = {
|
||||
|
@ -406,9 +399,15 @@ fn cache_substitutions(
|
|||
}
|
||||
}
|
||||
},
|
||||
prev_room,
|
||||
room,
|
||||
text: s.text,
|
||||
prev_rooms,
|
||||
rooms,
|
||||
text: if s.text.is_none()
|
||||
&& s.subst_type == db::models::SubstitutionType::RoomChange
|
||||
{
|
||||
Some("Raumänderung".to_string())
|
||||
} else {
|
||||
s.text
|
||||
},
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
|
|
37
bvplan/templates/base.html
Normal file
37
bvplan/templates/base.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de-DE">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="generator" content="BVplan" />
|
||||
<title>{% block title %}{% endblock %} | dergrimm.net</title>
|
||||
|
||||
<link rel="shortcut icon" href="/static/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
|
||||
<link rel="manifest" href="/static/site.webmanifest">
|
||||
|
||||
{% block head %}{% endblock %}
|
||||
|
||||
<!-- Matomo -->
|
||||
<script>
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//matomo.dergrimm.net/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '6']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Matomo Code -->
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
|
@ -1,171 +1,143 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de-DE">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="generator" content="BVplan" />
|
||||
<title>BVplan | dergrimm.net</title>
|
||||
{% extends "base.html" %}
|
||||
|
||||
<link rel="shortcut icon" href="/static/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
|
||||
<link rel="manifest" href="/static/site.webmanifest">
|
||||
{% block title %}BVplan{% endblock %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/bvplan.css" />
|
||||
{% block head %}
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/bvplan.css" />
|
||||
|
||||
<script id="data-element-count" type="application/json">{{ data.substitutions.len()|json|safe }}</script>
|
||||
<script id="data-element-count" type="application/json">{{ data.substitutions.len()|json|safe }}</script>
|
||||
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"
|
||||
integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js"
|
||||
integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
{% endblock %}
|
||||
|
||||
<!-- Matomo -->
|
||||
<script>
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//matomo.dergrimm.net/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '6']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Matomo Code -->
|
||||
</head>
|
||||
<body>
|
||||
<header id="info">
|
||||
<div id="title-wrapper" class="column">
|
||||
<h1 id="title">BVplan</h1>
|
||||
<span id="subtitle">dergrimm.net</span>
|
||||
</div>
|
||||
<div id="tenant-info" class="column">
|
||||
<span>{{ data.tenant }}, {{ data.schoolyear }}</span>
|
||||
<br />
|
||||
<span>Stand: {{ data.queried_at }}</span>
|
||||
<br />
|
||||
<span>Untis: {{ data.last_import_time }}</span>
|
||||
</div>
|
||||
</header>
|
||||
{% block body %}
|
||||
<header id="info">
|
||||
<div id="title-wrapper" class="column">
|
||||
<h1 id="title">BVplan</h1>
|
||||
<span id="subtitle">dergrimm.net</span>
|
||||
</div>
|
||||
<div id="tenant-info" class="column">
|
||||
<span>{{ data.tenant }}, {{ data.schoolyear }}</span>
|
||||
<br />
|
||||
<span>Stand: {{ data.queried_at }}</span>
|
||||
<br />
|
||||
<span>Vertretungsplan (offline): {{ data.last_import_time }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<table id="plan">
|
||||
<caption>
|
||||
{{ data.date }}, Woche {{ data.week_type }}
|
||||
</caption>
|
||||
<main>
|
||||
<table id="plan">
|
||||
<caption>
|
||||
{{ data.date }}, Woche {{ data.week_type }}
|
||||
</caption>
|
||||
|
||||
<colgroup>
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 30%" />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 20%" />
|
||||
</colgroup>
|
||||
<colgroup>
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 30%" />
|
||||
<col />
|
||||
<col />
|
||||
<col />
|
||||
<col style="width: 20%" />
|
||||
</colgroup>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stunde</th>
|
||||
<th>Klasse(n)</th>
|
||||
<th>(Fach)</th>
|
||||
<th>Fach</th>
|
||||
<th>Vertreter</th>
|
||||
<th>(Raum)</th>
|
||||
<th>Raum</th>
|
||||
<th>Text</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stunde</th>
|
||||
<th>Klasse(n)</th>
|
||||
<th>(Fach)</th>
|
||||
<th>Fach</th>
|
||||
<th>Vertreter</th>
|
||||
<th>(Raum)</th>
|
||||
<th>Raum</th>
|
||||
<th>Text</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for subst in data.substitutions %}
|
||||
<tr>
|
||||
<td>{{ subst.period }}</td>
|
||||
<td>{{ subst.classes|join(", ") }}</td>
|
||||
<td>
|
||||
{% match subst.prev_subject %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.subject %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.teachers %}
|
||||
{% when Some with (x) %}
|
||||
{{ x|join(", ") }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.prev_room %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.room %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.text %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
<tbody>
|
||||
{% for subst in data.substitutions %}
|
||||
<tr>
|
||||
<td>{{ subst.period }}</td>
|
||||
<td>{{ subst.classes|join(", ") }}</td>
|
||||
<td>
|
||||
{% match subst.prev_subject %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.subject %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.teachers %}
|
||||
{% when Some with (x) %}
|
||||
{{ x|join(", ") }}
|
||||
{% when None %}
|
||||
---
|
||||
{% endmatch %}
|
||||
</td>
|
||||
<td>
|
||||
{% if subst.prev_rooms.is_empty() %}
|
||||
---
|
||||
{% else %}
|
||||
{{ subst.prev_rooms|join(", ") }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if subst.rooms.is_empty() %}
|
||||
---
|
||||
{% else %}
|
||||
{{ subst.rooms|join(", ") }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% match subst.text %}
|
||||
{% when Some with (x) %}
|
||||
{{ x }}
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
|
||||
<footer id="footer">
|
||||
<div class="element">
|
||||
<p>
|
||||
BVplan - der bessre Vertretungsplan sogar mit UTF-8 Support!
|
||||
Wow
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://git.dergrimm.net/dergrimm/bvplan">
|
||||
https://git.dergrimm.net/dergrimm/bvplan
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<hr />
|
||||
<p class="element">
|
||||
<code>
|
||||
Powered by Dominic Grimm <<a
|
||||
href="mailto:dominic@dergrimm.net"
|
||||
>dominic@dergrimm.net</a
|
||||
>>, Untis sucks
|
||||
</code>
|
||||
<footer id="footer">
|
||||
<div class="element">
|
||||
<p>
|
||||
BVplan - der bessre Vertretungsplan sogar mit UTF-8 Support!
|
||||
Wow
|
||||
</p>
|
||||
</footer>
|
||||
<p>
|
||||
<a href="https://git.dergrimm.net/dergrimm/bvplan">
|
||||
https://git.dergrimm.net/dergrimm/bvplan
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<hr />
|
||||
<p class="element">
|
||||
<code>
|
||||
Powered by Dominic Grimm <<a
|
||||
href="mailto:dominic@dergrimm.net"
|
||||
>dominic@dergrimm.net</a
|
||||
>>, Untis sucks
|
||||
</code>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<script src="/static/js/bvplan.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<script src="/static/js/bvplan.js"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,47 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de-DE">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="generator" content="BVplan" />
|
||||
<title>BVplan | dergrimm.net</title>
|
||||
{% extends "base.html" %}
|
||||
|
||||
<link rel="shortcut icon" href="/static/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
|
||||
<link rel="manifest" href="/static/site.webmanifest">
|
||||
{% block title %}{{ status_code.as_str() }}{% endblock %}
|
||||
|
||||
<style>
|
||||
body {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
{% block head %}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>{{ status_code }}</h1>
|
||||
{% match message %}
|
||||
{% when Some with (x) %}
|
||||
<hr />
|
||||
<p>{{ x }}</p>
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- Matomo -->
|
||||
<script>
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//matomo.dergrimm.net/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '6']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Matomo Code -->
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ status_code }}</h1>
|
||||
{% match message %}
|
||||
{% when Some with (x) %}
|
||||
<hr />
|
||||
<p>{{ x }}</p>
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue