Support of teacher absence format: "za Vn zastupuje Jk"
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user