aboutsummaryrefslogtreecommitdiff
path: root/update.js
diff options
context:
space:
mode:
authorJoelHMikael <joel.h.kronqvist@gmail.com>2022-01-18 18:38:13 +0200
committerJoelHMikael <joel.h.kronqvist@gmail.com>2022-01-18 18:38:13 +0200
commitf0d41b4b7ef5faff8fbc84de9175f67746a5a8b3 (patch)
treec8068acc93527aebb3e1bb62d0effd2721327898 /update.js
parent09fc091ef196849e85bfef12edc5be9e29b8d528 (diff)
downloadLYLLRuoka-f0d41b4b7ef5faff8fbc84de9175f67746a5a8b3.tar.gz
LYLLRuoka-f0d41b4b7ef5faff8fbc84de9175f67746a5a8b3.zip
Updating separated from server, lightweight analytics added
Diffstat (limited to 'update.js')
-rw-r--r--update.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/update.js b/update.js
new file mode 100644
index 0000000..9262ff7
--- /dev/null
+++ b/update.js
@@ -0,0 +1,21 @@
+const database = require("./database.js");
+const openFile = require("./open.js").file;
+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(shiftfile = "./shifts.txt", classfile = "./classes.txt", dbcredentials)
+{
+ let shiftCont = await openFile(shiftfile);
+ const DB = new database.Database(JSON.parse(dbcredentials));
+ shiftCont = shiftCont.toString("utf-8").replaceAll("\r", ""); // \r because of the \r\n newline on windows which creates problems
+ await Promise.all([
+ parseClasses(classfile[0], classfile[1], DB),
+ parse.build(shiftCont, DB)
+ ]);
+ return 0;
+}
+
+exports.update = buildDB;
+// Example call:
+// await updateDB.update("./shifts.txt", ["./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt"], dbcredentials); \ No newline at end of file