feat: Add stages for processing university schedule and authentication logs

- Implemented `stage_parse_schedule.py` to normalize and prepare university schedule data.
- Created `stage_process_logs.py` for processing authentication logs and generating session records.
- Added necessary classes and methods for log entry parsing, session extraction, and CSV output.
- Updated `settings.yaml` with new schedule and processing configurations.
- Introduced new templates and styles for report generation, including HTML and CSS files.
- Added main entry point `run.py` to execute the attendance processing pipeline.
- Included `.gitkeep` files in `output` and `result` directories to maintain structure.
This commit is contained in:
2026-05-08 11:20:13 +04:00
parent 73416ac315
commit c11c9e8aa8
22 changed files with 4047 additions and 30 deletions
+498
View File
@@ -0,0 +1,498 @@
:root {
color-scheme: light;
--bg: #f7f8fb;
--panel: #ffffff;
--text: #1b1f2a;
--muted: #667085;
--line: #d9e0ea;
--accent: #2563eb;
--accent-2: #0f766e;
--shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
--bad: #ef4444;
--warn: #f59e0b;
--good: #22c55e;
--empty: #e5e7eb;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
color: var(--text);
background: var(--bg);
}
.page {
max-width: 1440px;
margin: 0 auto;
padding: 24px;
}
.header {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
margin-bottom: 18px;
}
.title h1 {
margin: 0 0 8px;
font-size: 30px;
}
.title p {
margin: 0;
color: var(--muted);
}
.actions {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.btn {
border: 1px solid var(--line);
background: var(--panel);
border-radius: 12px;
padding: 10px 14px;
cursor: pointer;
box-shadow: var(--shadow);
}
.btn.primary {
background: linear-gradient(135deg, var(--accent), #4f46e5);
color: white;
border-color: transparent;
}
.section,
.class-block,
.screen-nav,
.print-nav {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 18px;
box-shadow: var(--shadow);
}
.section {
padding: 20px;
}
.section h2,
.print-nav h2 {
margin: 0 0 16px;
font-size: 22px;
}
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 14px;
margin-bottom: 18px;
}
.card {
border: 1px solid var(--line);
border-radius: 16px;
padding: 16px;
background: linear-gradient(180deg, #fff, #fbfcff);
}
.card-value {
font-size: 26px;
font-weight: 700;
line-height: 1.1;
}
.card-label {
color: var(--muted);
margin-top: 6px;
}
.muted { color: var(--muted); }
.screen-nav {
padding: 14px;
margin-bottom: 20px;
}
.section-nav,
.class-nav-group {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.class-nav {
margin-top: 12px;
}
.class-nav-group { display: none; }
.class-nav-group.active { display: flex; }
.nav-btn {
border: 1px solid var(--line);
background: #fff;
color: var(--text);
border-radius: 999px;
padding: 10px 14px;
cursor: pointer;
transition: 0.15s ease;
}
.nav-btn:hover { border-color: var(--accent); }
.nav-btn.active {
background: var(--accent);
border-color: var(--accent);
color: #fff;
}
.print-nav {
display: none;
padding: 18px 20px;
margin-bottom: 20px;
}
.print-nav-section + .print-nav-section { margin-top: 14px; }
.print-nav-section h3 { margin: 0 0 8px; }
.print-nav-section ul { margin: 0; padding-left: 18px; }
.report-section { margin-bottom: 26px; }
.class-block {
display: none;
padding: 20px;
margin-bottom: 18px;
}
.class-block.active { display: block; }
.class-head {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
margin-bottom: 14px;
}
.class-kicker {
color: var(--muted);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.06em;
margin-bottom: 4px;
}
.class-head h3 {
margin: 0;
font-size: 24px;
}
.class-note {
margin-top: 6px;
color: var(--muted);
font-size: 13px;
}
.class-chart {
overflow-x: auto;
margin-bottom: 16px;
}
.week-chart {
width: 100%;
height: auto;
min-width: 720px;
}
.chart-week-label {
font-size: 12px;
fill: var(--text);
}
.chart-count {
font-size: 12px;
fill: var(--text);
font-weight: 600;
}
.week-bar.code-1 { fill: var(--bad); }
.week-bar.code-2 { fill: var(--warn); }
.week-bar.code-3 { fill: var(--good); }
.class-table,
.scheme-table,
.table {
width: 100%;
border-collapse: collapse;
}
.class-table th,
.class-table td,
.scheme-table th,
.scheme-table td,
.table th,
.table td {
border-bottom: 1px solid var(--line);
padding: 10px 12px;
vertical-align: top;
text-align: left;
}
.class-table th,
.scheme-table th,
.table th {
font-size: 13px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.04em;
background: #f8fafc;
}
.week-label { white-space: nowrap; }
.num { white-space: nowrap; }
.scheme-cell-wrap { min-width: 420px; }
.scheme-table {
width: 100%;
min-width: 420px;
border: 1px solid var(--line);
border-radius: 12px;
overflow: hidden;
}
.scheme-table th,
.scheme-table td {
padding: 6px;
text-align: center;
}
.scheme-table thead th:first-child,
.scheme-table tbody th {
text-align: left;
white-space: nowrap;
}
.scheme-cell {
display: inline-block;
width: 18px;
height: 18px;
border-radius: 4px;
background: var(--empty);
border: 1px solid rgba(0, 0, 0, 0.06);
}
.scheme-cell.code-0 { background: var(--empty); }
.scheme-cell.code-1 { background: var(--bad); }
.scheme-cell.code-2 { background: var(--warn); }
.scheme-cell.code-3 { background: var(--good); }
.code-1 { color: var(--bad); }
.code-2 { color: var(--warn); }
.code-3 { color: var(--good); }
@media print {
body { background: #fff; }
.page { max-width: none; padding: 0; }
.screen-nav,
.actions { display: none !important; }
.print-nav { display: block; }
.class-block { display: block !important; box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
.section, .class-block, .print-nav { box-shadow: none; }
.table th, .class-table th { position: static; }
}
:root {
color-scheme: light;
--bg: #f7f8fb;
--panel: #ffffff;
--text: #1b1f2a;
--muted: #667085;
--line: #d9e0ea;
--accent: #2563eb;
--accent-2: #0f766e;
--shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
color: var(--text);
background: var(--bg);
}
.page {
max-width: 1400px;
margin: 0 auto;
padding: 24px;
}
.header {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
margin-bottom: 20px;
}
.title h1 {
margin: 0 0 8px;
font-size: 30px;
}
.title p {
margin: 0;
color: var(--muted);
}
.actions {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.btn {
border: 1px solid var(--line);
background: var(--panel);
border-radius: 12px;
padding: 10px 14px;
cursor: pointer;
box-shadow: var(--shadow);
}
.btn.primary {
background: linear-gradient(135deg, var(--accent), #4f46e5);
color: white;
border-color: transparent;
}
.section {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 18px;
padding: 20px;
margin-bottom: 20px;
box-shadow: var(--shadow);
}
.section h2 {
margin: 0 0 16px;
font-size: 22px;
}
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 14px;
}
.card {
border: 1px solid var(--line);
border-radius: 16px;
padding: 16px;
background: linear-gradient(180deg, #fff, #fbfcff);
}
.card-value {
font-size: 26px;
font-weight: 700;
line-height: 1.1;
}
.card-label {
color: var(--muted);
margin-top: 6px;
}
.table {
width: 100%;
border-collapse: collapse;
}
.table th,
.table td {
border-bottom: 1px solid var(--line);
padding: 10px 12px;
vertical-align: top;
text-align: left;
}
.table th {
font-size: 13px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.04em;
background: #f8fafc;
position: sticky;
top: 0;
z-index: 1;
}
.muted { color: var(--muted); }
.pill {
display: inline-block;
padding: 4px 8px;
border-radius: 999px;
background: #e8eefb;
color: #274a8a;
font-size: 12px;
font-weight: 600;
}
.grid-2 {
display: grid;
grid-template-columns: 1.3fr 1fr;
gap: 16px;
}
.chart-wrap {
min-height: 80px;
overflow-x: auto;
}
.bar-chart {
width: 100%;
height: auto;
overflow: visible;
}
.chart-label {
font-size: 12px;
fill: #1b1f2a;
dominant-baseline: middle;
}
.chart-value {
font-size: 12px;
fill: #334155;
dominant-baseline: middle;
font-weight: 600;
}
.chart-track { fill: #e8edf5; }
.chart-bar { fill: var(--accent); }
.chart-bar.secondary { fill: var(--accent-2); }
.note {
padding: 14px 16px;
border-left: 4px solid var(--accent);
background: #eff6ff;
border-radius: 12px;
margin-bottom: 18px;
}
.nowrap { white-space: nowrap; }
@media print {
body { background: white; }
.page { max-width: none; padding: 0; }
.actions { display: none; }
.section, .card { box-shadow: none; }
.section { break-inside: avoid; }
.table th { position: static; }
}
+141
View File
@@ -0,0 +1,141 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<style>
{{ css_text | safe }}
</style>
</head>
<body>
<div class="page">
<header class="header">
<div class="title">
<h1>{{ title }}</h1>
<p>{{ hint }}</p>
</div>
<div class="actions">
<button class="btn primary" onclick="printReport()">Печать / PDF</button>
</div>
</header>
<section class="screen-nav" aria-label="Навигация по отчёту">
<div class="section-nav">
{% for section in report.sections %}
<button type="button" class="nav-btn{% if section.id == report.active_section %} active{% endif %}" data-section="{{ section.id }}">{{ section.title }}</button>
{% endfor %}
</div>
<div class="class-nav">
{% for section in report.sections %}
<div class="class-nav-group{% if section.id == report.active_section %} active{% endif %}" data-section="{{ section.id }}">
{% for item in section.items %}
<button type="button" class="nav-btn class-btn{% if item.id == report.active_class %} active{% endif %}" data-section="{{ section.id }}" data-class-id="{{ item.id }}">{{ item.label }}</button>
{% endfor %}
</div>
{% endfor %}
</div>
</section>
<nav class="print-nav" aria-label="Печатная навигация">
<h2>Навигация</h2>
{% for section in report.sections %}
<section class="print-nav-section">
<h3>{{ section.title }}</h3>
<ul>
{% for item in section.items %}
<li><a href="#class-{{ item.id }}">{{ item.label }}</a></li>
{% endfor %}
</ul>
</section>
{% endfor %}
</nav>
<div class="report-sections">
{% for section in report.sections %}
<section class="report-section" data-section="{{ section.id }}">
{% for item in section.items %}
<article class="class-block{% if item.id == report.active_class %} active{% endif %}"
id="class-{{ item.id }}"
data-section="{{ section.id }}"
data-class-id="{{ item.id }}">
<div class="class-head">
<div>
<div class="class-kicker">{{ section.title }}</div>
<h3>{{ item.label }}</h3>
{% if item.source_labels %}
<div class="class-note">{{ item.source_labels | join(', ') }}</div>
{% endif %}
</div>
</div>
<div class="class-chart">
{{ item.chart_svg | safe }}
</div>
<div class="class-table-wrap">
<table class="class-table">
<thead>
<tr>
<th>Неделя</th>
<th>Всего пар</th>
<th>Пар проведено</th>
<th>Пар пропущено</th>
<th>Иные пары</th>
<th>Схема</th>
</tr>
</thead>
<tbody>
{% for week in item.weeks %}
<tr>
<td class="week-label">{{ week.long }}</td>
<td class="num">{{ week.total_pairs }}</td>
<td class="num">{{ week.conducted_display }}</td>
<td class="num">{{ week.missed_display }}</td>
<td class="num">{{ week.other_display }}</td>
<td class="scheme-cell-wrap">{{ week.scheme_html | safe }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</article>
{% endfor %}
</section>
{% endfor %}
</div>
</div>
<script>
window.__CLASS_REPORT__ = {{ report_json | safe }};
</script>
<script>
{{ js_text | safe }}
</script>
</body>
</html>
<!doctype html>
<html lang='ru'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>{{TITLE}}</title>
{{STYLE_TAG}}
</head>
<body>
<div class='page'>
<div class='header'>
<div class='title'>
<h1>{{TITLE}}</h1>
<p>{{HINT}}</p>
</div>
<div class='actions'>
<button class='btn primary' onclick='printReport()'>Печать / PDF</button>
</div>
</div>
{{CONTENT}}
</div>
{{SCRIPT_TAG}}
</body>
</html>
+73
View File
@@ -0,0 +1,73 @@
(function () {
function qs(selector, root) {
return (root || document).querySelector(selector);
}
function qsa(selector, root) {
return Array.from((root || document).querySelectorAll(selector));
}
function setActiveSection(sectionId) {
qsa('.section-nav .nav-btn[data-section]').forEach((btn) => {
btn.classList.toggle('active', btn.dataset.section === sectionId);
});
qsa('.class-nav-group').forEach((group) => {
group.classList.toggle('active', group.dataset.section === sectionId);
});
const firstButton = qs(`.class-nav-group.active .class-btn[data-class-id]`);
if (firstButton) {
setActiveClass(firstButton.dataset.classId, false);
}
}
function setActiveClass(classId, scrollIntoView) {
qsa('.class-btn[data-class-id]').forEach((btn) => {
btn.classList.toggle('active', btn.dataset.classId === classId);
});
qsa('.class-block[data-class-id]').forEach((block) => {
const active = block.dataset.classId === classId;
block.classList.toggle('active', active);
if (active && scrollIntoView) {
block.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
}
function init() {
const report = window.__CLASS_REPORT__ || {};
const activeSection = report.active_section || '';
const activeClass = report.active_class || '';
qsa('.section-nav .nav-btn[data-section]').forEach((btn) => {
btn.addEventListener('click', () => setActiveSection(btn.dataset.section));
});
qsa('.class-btn[data-class-id]').forEach((btn) => {
btn.addEventListener('click', () => setActiveClass(btn.dataset.classId, true));
});
if (activeSection) {
setActiveSection(activeSection);
}
if (activeClass) {
setActiveClass(activeClass, false);
}
}
window.printReport = function printReport() {
window.print();
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
function printReport() {
window.print();
}
+77
View File
@@ -0,0 +1,77 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<style>
{{ css_text | safe }}
</style>
</head>
<body>
<div class="page">
<header class="header">
<div class="title">
<h1>{{ title }}</h1>
<p>{{ hint }}</p>
</div>
<div class="actions">
<button class="btn primary" onclick="printReport()">Печать / PDF</button>
</div>
</header>
<section class="section">
<h2>Шаблон пар</h2>
{% if report.lesson_windows %}
<table class="table">
<thead>
<tr><th>Пара</th><th>Начало</th><th>Окончание</th></tr>
</thead>
<tbody>
{% for item in report.lesson_windows %}
<tr>
<td>{{ item.lesson }}</td>
<td>{{ item.start }}</td>
<td>{{ item.end }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="muted">Нет данных.</div>
{% endif %}
</section>
</div>
<script>
window.__GROUP_REPORT__ = {{ report_json | safe }};
</script>
<script>
{{ js_text | safe }}
</script>
</body>
</html>
<!doctype html>
<html lang='ru'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>{{TITLE}}</title>
{{STYLE_TAG}}
</head>
<body>
<div class='page'>
<div class='header'>
<div class='title'>
<h1>{{TITLE}}</h1>
<p>{{HINT}}</p>
</div>
<div class='actions'>
<button class='btn primary' onclick='printReport()'>Печать / PDF</button>
</div>
</div>
{{CONTENT}}
</div>
{{SCRIPT_TAG}}
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
window.printReport = function printReport() {
window.print();
};
function printReport() {
window.print();
}