1
0

fix: Exkurze shit
All checks were successful
Remote Deploy / deploy (push) Successful in 5s

This commit is contained in:
2026-02-09 19:26:55 +01:00
parent 75d8ba745f
commit cfdd97c935
2 changed files with 31 additions and 0 deletions

View File

@@ -116,6 +116,28 @@ export default function parseAbsence(input, teacherMap = {}) {
markConsumed(matchStart, matchEnd); markConsumed(matchStart, matchEnd);
} }
// 1a. Teachers with "-startHour-exk" suffix (e.g. "Sv-5-exk")
const teacherStartExkRe = /([A-Za-z]+)-(\d+)-exk/gi;
while ((m = teacherStartExkRe.exec(s)) !== null) {
const matchStart = m.index;
const matchEnd = teacherStartExkRe.lastIndex;
if (isConsumed(matchStart)) continue;
const teacherCode = m[1];
const from = Number(m[2]);
const { name } = resolveTeacher(teacherCode, teacherMap);
if (from >= 1 && from <= LAST_HOUR) {
results.push({
teacher: name,
teacherCode: teacherCode.toLowerCase(),
type: "exkurze",
hours: { from, to: LAST_HOUR },
});
markConsumed(matchStart, matchEnd);
}
}
// 2. Teachers with "-exk" suffix // 2. Teachers with "-exk" suffix
const teacherExkRe = /([A-Za-z]+)-exk/gi; const teacherExkRe = /([A-Za-z]+)-exk/gi;
while ((m = teacherExkRe.exec(s)) !== null) { while ((m = teacherExkRe.exec(s)) !== null) {

View File

@@ -248,6 +248,15 @@ test("Vc 1. h", [
}, },
]); ]);
test("Sv-5-exk", [
{
teacher: "Ing. Jan Šváb",
teacherCode: "sv",
type: "exkurze",
hours: { from: 5, to: 10 },
},
]);
function test(input, expectedOutput) { function test(input, expectedOutput) {
const res = parseAbsence(input, teachermap); const res = parseAbsence(input, teachermap);