aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@gmail.com>2022-10-25 19:30:56 +0300
committerJoel Kronqvist <work.joelkronqvist@gmail.com>2022-10-25 19:30:56 +0300
commit04726443dce96f4b41f3506a2e6570db52b944ef (patch)
tree570878f146a23b35c82465b793b19c42385ad432
parentbd8e36aec2c6a78594c34066edc34b309cac2e0c (diff)
downloadLYLLRuoka-04726443dce96f4b41f3506a2e6570db52b944ef.tar.gz
LYLLRuoka-04726443dce96f4b41f3506a2e6570db52b944ef.zip
Fixed bugs from last commit
-rw-r--r--dbparse.js29
-rw-r--r--server.js11
2 files changed, 31 insertions, 9 deletions
diff --git a/dbparse.js b/dbparse.js
index f196c78..0f029b4 100644
--- a/dbparse.js
+++ b/dbparse.js
@@ -117,25 +117,38 @@ async function writeShift(weekday, shiftId, shiftLine, courseLine, DB)
const teacher = course[3] || null;
// Get the class
- let className = await DB.execute(
+ let className1 = await DB.execute(
"SELECT class FROM classes WHERE course=?",
- [courseName]
+ [courseName1]
);
- if (className !== undefined)
- className = className.class;
+ className1 = className1[0];
+ if (className1 !== undefined)
+ className1 = className1.class;
else
- className = null;
- className = className[0];
+ className1 = null;
+
+ let className2 = undefined;
+ if (courseName2 !== undefined) {
+ className2 = await DB.execute(
+ "SELECT class FROM classes WHERE course=?",
+ [courseName2]
+ );
+ className2 = className2[0];
+ if (className2 !== undefined)
+ className2 = className2.class;
+ else
+ className2 = null;
+ }
// Add the info
dbOperations.push(DB.execute(
`INSERT IGNORE INTO shifts VALUES (${weekday}, ${shiftId}, ?, ?, ?)`,
- [courseName1, teacher, className]
+ [courseName1, teacher, className1]
));
if (courseName2 !== null) {
dbOperations.push(DB.execute(
`INSERT IGNORE INTO shifts VALUES (${weekday}, ${shiftId}, ?, ?, ?)`,
- [courseName2, teacher, className]
+ [courseName2, teacher, className2]
));
}
}
diff --git a/server.js b/server.js
index 5b51eee..11c50bd 100644
--- a/server.js
+++ b/server.js
@@ -207,13 +207,22 @@ async function buildMain(args)
if (res["shift"] === undefined)
{
let shift = await DBPARSE.get(day, index, SQLDB);
+ // shift looks like the following: (useful info for debugging. this is really obscure without any information about how this variable looks like.)
+ /*[
+ {
+ name: 'RUOKAILUVUORO I: ruokailu klo 10.50 – 11.20, oppitunti klo 11.30 – 12.50'
+ },
+ [ { course: 'OPO15', teacher: null, class: null } ]
+ ]*/
if (shift !== undefined)
{
res["shift"] = shift[0].name;
res["shift-header"] = "";
for (let i = 0; i < shift[1].length; i++)
{
- res["shift-header"] += `${shift[1][i].course}/${shift[1][i].teacher}`;
+ res["shift-header"] += `${shift[1][i].course}`;
+ if (shift[1][i].teacher !== null)
+ res["shift-header"] += `/${shift[1][i].teacher}`;
if (shift[1][i].class !== null)
res["shift-header"] += `/${shift[1][i].class}`
if (i + 1 !== shift[1].length)