fix: Another fucking teacher absence
All checks were successful
Remote Deploy / deploy (push) Successful in 9s
All checks were successful
Remote Deploy / deploy (push) Successful in 9s
This commit is contained in:
@@ -156,6 +156,29 @@ export default function parseAbsence(input: string, teacherMap: TeacherMap = {})
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1b. Teachers with "-exk" followed by spec (e.g. "Ex-exk. 3+")
|
||||||
|
const teacherExkWithSpecRe = /([A-Za-z]+)-exk(?:\.)?\s*(\d+(?:\+|-\d+|,\d+)?)/gi;
|
||||||
|
while ((m = teacherExkWithSpecRe.exec(s)) !== null) {
|
||||||
|
const matchStart = m.index;
|
||||||
|
const matchEnd = teacherExkWithSpecRe.lastIndex;
|
||||||
|
if (isConsumed(matchStart)) continue;
|
||||||
|
|
||||||
|
const teacherCode = m[1];
|
||||||
|
const specStr = m[2];
|
||||||
|
const spec = parseSpec(specStr);
|
||||||
|
|
||||||
|
if (spec) {
|
||||||
|
const { name } = resolveTeacher(teacherCode, teacherMap);
|
||||||
|
results.push({
|
||||||
|
teacher: name,
|
||||||
|
teacherCode: teacherCode.toLowerCase(),
|
||||||
|
type: "exkurze",
|
||||||
|
hours: spec.value,
|
||||||
|
});
|
||||||
|
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) {
|
||||||
|
|||||||
@@ -259,6 +259,33 @@ test("Sv-5-exk", [
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
test("Ex-exk. 3+", [
|
||||||
|
{
|
||||||
|
teacher: "Ing. Jana Exnerová",
|
||||||
|
teacherCode: "ex",
|
||||||
|
type: "exkurze",
|
||||||
|
hours: { from: 3, to: 10 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
test("Ex-exk.3+", [
|
||||||
|
{
|
||||||
|
teacher: "Ing. Jana Exnerová",
|
||||||
|
teacherCode: "ex",
|
||||||
|
type: "exkurze",
|
||||||
|
hours: { from: 3, to: 10 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
test("Ex-exk. 3", [
|
||||||
|
{
|
||||||
|
teacher: "Ing. Jana Exnerová",
|
||||||
|
teacherCode: "ex",
|
||||||
|
type: "exkurze",
|
||||||
|
hours: 3,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
function test(input: string, expectedOutput: any[]) {
|
function test(input: string, expectedOutput: any[]) {
|
||||||
const res = parseAbsence(input, teachermap);
|
const res = parseAbsence(input, teachermap);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user