aboutsummaryrefslogtreecommitdiff
path: root/update.js
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-10 10:40:10 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-10 10:40:10 +0200
commit01f3f5f2ab89432a253c24f76227b8f6855d8446 (patch)
tree94ae04efb6b93a328ba43f14847f2fd3f3d6d07c /update.js
parentfd329fac83ca83b768dbb39a17ea789cc8cdb65b (diff)
downloadLYLLRuoka-01f3f5f2ab89432a253c24f76227b8f6855d8446.tar.gz
LYLLRuoka-01f3f5f2ab89432a253c24f76227b8f6855d8446.zip
Class parsing with any number of files with classes
Diffstat (limited to 'update.js')
-rw-r--r--update.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/update.js b/update.js
index a63ee3e..a78b57a 100644
--- a/update.js
+++ b/update.js
@@ -4,13 +4,14 @@ 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)
+async function buildDB(dbcredentials, shiftPath, ...classfiles)
{
- let shiftCont = await openFile(shiftfile);
+ let shiftCont = await openFile(shiftPath);
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),
+ parseClasses(DB, ...classfiles),
parse.build(shiftCont, DB)
]);
return 0;
@@ -20,6 +21,6 @@ exports.update = buildDB;
// Example call:
/*
const openFile = require("./Functions/open.js").file;
-const dbcredentials = openFile("../dblogin.txt");
-await updateDB.update("./shifts.txt", ["./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt"], dbcredentials);
+const dbcredentials = await openFile("../dblogin.txt");
+await updateDB.update(dbcredentials, "./shifts.txt", "./Kurssitarjottimet/2016Classes.txt", "./Kurssitarjottimet/NewClasses.txt");
*/ \ No newline at end of file