diff options
author | Joel Kronqvist <work.joelkronqvist@gmail.com> | 2022-10-25 19:30:56 +0300 |
---|---|---|
committer | Joel Kronqvist <work.joelkronqvist@gmail.com> | 2022-10-25 19:30:56 +0300 |
commit | 04726443dce96f4b41f3506a2e6570db52b944ef (patch) | |
tree | 570878f146a23b35c82465b793b19c42385ad432 /dbparse.js | |
parent | bd8e36aec2c6a78594c34066edc34b309cac2e0c (diff) | |
download | LYLLRuoka-04726443dce96f4b41f3506a2e6570db52b944ef.tar.gz LYLLRuoka-04726443dce96f4b41f3506a2e6570db52b944ef.zip |
Fixed bugs from last commit
Diffstat (limited to 'dbparse.js')
-rw-r--r-- | dbparse.js | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -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] )); } } |