aboutsummaryrefslogtreecommitdiff
path: root/update.js
diff options
context:
space:
mode:
authorJoel Kronqvist <joelkronqvist@proton.me>2023-06-21 14:18:27 +0300
committerJoel Kronqvist <joelkronqvist@proton.me>2023-06-21 14:18:27 +0300
commitc6eb85c138c267db08103de28a3a7c6dffee6c4f (patch)
tree5c55ba312926d61a13b04b32c9b801120b92fe78 /update.js
parent529477dc21ec03842ac55a2719b0875133d2aa43 (diff)
downloadLYLLRuoka-c6eb85c138c267db08103de28a3a7c6dffee6c4f.tar.gz
LYLLRuoka-c6eb85c138c267db08103de28a3a7c6dffee6c4f.zip
Rescued WIP Shift, class and exception updation
Diffstat (limited to 'update.js')
-rw-r--r--update.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/update.js b/update.js
index 9a0c027..be7794c 100644
--- a/update.js
+++ b/update.js
@@ -3,15 +3,20 @@ const parseClasses = require("./parseClasses.js").classes;
const parse = require("./dbparse.js");
// Run this if you want to build the database from text files
-async function buildDB(dbconnection, shiftPath, ...classfiles)
-{
+async function buildDB(dbconnection, shiftPath, classPath, exceptionPath) {
let shiftCont = await openFile(shiftPath);
- shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which may create problems
+ shiftCont = shiftCont.toString("utf-8");
+
+ let exceptions = await openFile(exceptionPath);
+ exceptions = exceptions.toString("utf-8");
+
+ let classes = await openFile(classPath);
+ classes = classes.toString('utf-8');
+
+ await parseClasses(dbconnection, classes);
+ await parse.build(shiftCont, dbconnection);
+ await updateExceptions(exceptions, dbconnection);
- await parseClasses(dbconnection, ...classfiles),
- console.log("Classes updated.");
- await parse.build(shiftCont, dbconnection)
- console.log("Shifts updated.");
return 0;
}
@@ -22,5 +27,5 @@ const openFile = require("./Functions/open.js").file;
const database = require("./database.js");
const dbcredentials = await openFile("../dblogin.txt");
const DB = new database.Database(JSON.parse(dbcredentials));
-await updateDB.update(dbcredentials, "./shifts.txt", "./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt");
+await updateDB.update(DB, "./shifts.txt", "./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt");
*/