1
0

feat: v2
All checks were successful
Remote Deploy / deploy (push) Successful in 1m11s

Support of teacher absence format: "za Vn zastupuje Jk"
This commit is contained in:
2026-01-04 14:02:10 +01:00
parent 0325ce1815
commit 6b383b1af4
7 changed files with 95 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ import fs from "fs"
import parseAbsence from "../utils/parseAbsence.js"
import parseTeachers from "../utils/parseTeachers.js"
export default async function parseV1(downloadedFilePath) {
export default async function parseV1V2(downloadedFilePath) {
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(downloadedFilePath);
const teacherMap = await parseTeachers();
@@ -216,7 +216,29 @@ export default async function parseV1(downloadedFilePath) {
}
}
fs.writeFileSync("db/v1.json", JSON.stringify(data, null, 2));
fs.writeFileSync("db/v2.json", JSON.stringify(data, null, 2));
// Modify the data for v1
const copy = JSON.parse(JSON.stringify(data));
copy.schedule.forEach(day => {
if (!Array.isArray(day.ABSENCE)) return;
day.ABSENCE = day.ABSENCE.map(old => {
if (old.type === "zastoupen") {
console.log("pepa")
return {
teacher: old.teacher,
teacherCode: old.teacherCode,
type: "wholeDay",
hours: null
};
}
return old;
});
});
fs.writeFileSync("db/v1.json", JSON.stringify(copy, null, 2))
}
//parseThisShit("downloads/table.xlsx")
parseV1V2("db/current.xlsx")