fix: Another another fucking teacher absence
All checks were successful
Remote Deploy / deploy (push) Successful in 1m20s
All checks were successful
Remote Deploy / deploy (push) Successful in 1m20s
Co-authored-by: Jakub Žitník <email@jzitnik.dev>
This commit is contained in:
@@ -40,6 +40,9 @@ export interface AbsenceResult {
|
||||
|
||||
export const parseSpec = (spec: string | null): Spec | null => {
|
||||
if (!spec) return null;
|
||||
|
||||
spec = spec.replace(/\s+/g, "");
|
||||
|
||||
let m;
|
||||
|
||||
// Handle "6,7"
|
||||
@@ -118,7 +121,7 @@ export default function parseAbsence(input: string, teacherMap: TeacherMap = {})
|
||||
|
||||
// 1. Teachers with specific hours (e.g. "Ab 1-4")
|
||||
const teacherListThenSpecRe =
|
||||
/([A-Za-z]+(?:[,;]\s?[A-Za-z]+)*)(?:\s*)(\d+(?:\+|-\d+|,\d+)?)(?:\.\s*h)?(?![A-Za-z])/g;
|
||||
/([A-Za-z]+(?:[,;]\s?[A-Za-z]+)*)(?:\s*)(\d+(?:\s*\+|\s*-\s*\d+|\s*,\s*\d+)?)(?:\.\s*h)?(?![A-Za-z])/g;
|
||||
|
||||
let m;
|
||||
while ((m = teacherListThenSpecRe.exec(s)) !== null) {
|
||||
@@ -157,7 +160,7 @@ 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;
|
||||
const teacherExkWithSpecRe = /([A-Za-z]+)-exk(?:\.)?\s*(\d+(?:\s*\+|\s*-\s*\d+|\s*,\s*\d+)?)/gi;
|
||||
while ((m = teacherExkWithSpecRe.exec(s)) !== null) {
|
||||
const matchStart = m.index;
|
||||
const matchEnd = teacherExkWithSpecRe.lastIndex;
|
||||
@@ -251,7 +254,7 @@ export default function parseAbsence(input: string, teacherMap: TeacherMap = {})
|
||||
}
|
||||
|
||||
// 5. Bare specs without teacher → invalid
|
||||
const specOnlyRe = /\b(\d+(?:\+|-\d+|,\d+)?)\b/g;
|
||||
const specOnlyRe = /\b(\d+(?:\s*\+|\s*-\s*\d+|\s*,\s*\d+)?)\b/g;
|
||||
while ((m = specOnlyRe.exec(s)) !== null) {
|
||||
const matchStart = m.index;
|
||||
if (isConsumed(matchStart)) continue;
|
||||
|
||||
Reference in New Issue
Block a user