Showing
1 changed file
with
10 additions
and
8 deletions
| ... | @@ -15,6 +15,7 @@ function jcalToSQL(jcal, userID) { | ... | @@ -15,6 +15,7 @@ function jcalToSQL(jcal, userID) { |
| 15 | connection.connect(); | 15 | connection.connect(); |
| 16 | 16 | ||
| 17 | const commonCols = [ | 17 | const commonCols = [ |
| 18 | + "userID", | ||
| 18 | "uid", | 19 | "uid", |
| 19 | "label", | 20 | "label", |
| 20 | "subjectID", | 21 | "subjectID", |
| ... | @@ -22,27 +23,28 @@ function jcalToSQL(jcal, userID) { | ... | @@ -22,27 +23,28 @@ function jcalToSQL(jcal, userID) { |
| 22 | "description", | 23 | "description", |
| 23 | "url", | 24 | "url", |
| 24 | "detail", | 25 | "detail", |
| 25 | - "status", | ||
| 26 | ]; | 26 | ]; |
| 27 | const dateScheCols = [...commonCols, "date"]; | 27 | const dateScheCols = [...commonCols, "date"]; |
| 28 | const timeScheCols = [...commonCols, "date", "startTime", "endTime"]; | 28 | const timeScheCols = [...commonCols, "date", "startTime", "endTime"]; |
| 29 | const dateQueryString = | 29 | const dateQueryString = |
| 30 | - "INSERT IGNORE INTO schedules_date (userID," + | 30 | + "INSERT IGNORE INTO schedules_date (" + |
| 31 | dateScheCols.join(",") + | 31 | dateScheCols.join(",") + |
| 32 | ") VALUES ?"; | 32 | ") VALUES ?"; |
| 33 | const timeQueryString = | 33 | const timeQueryString = |
| 34 | - "INSERT IGNORE INTO schedules_time (userID," + | 34 | + "INSERT IGNORE INTO schedules_time (" + |
| 35 | timeScheCols.join(",") + | 35 | timeScheCols.join(",") + |
| 36 | ") VALUES ?"; | 36 | ") VALUES ?"; |
| 37 | 37 | ||
| 38 | const dateSchedules = []; | 38 | const dateSchedules = []; |
| 39 | const timeSchedules = []; | 39 | const timeSchedules = []; |
| 40 | for (const sche of jcal) { | 40 | for (const sche of jcal) { |
| 41 | - if (sche.scheType === "date") { | 41 | + sche.userID = userID; |
| 42 | - dateSchedules.push([userID, ...dateScheCols.map((col) => sche[col])]); | 42 | + sche.type = "assignment"; |
| 43 | - } else if (sche.scheType === "time") { | 43 | + if (sche.scheType === "date") |
| 44 | - timeSchedules.push([userID, ...timeScheCols.map((col) => sche[col])]); | 44 | + dateSchedules.push(dateScheCols.map((col) => sche[col])); |
| 45 | - } else console.log("unexpected scheType", sche); | 45 | + else if (sche.scheType === "time") |
| 46 | + timeSchedules.push(timeScheCols.map((col) => sche[col])); | ||
| 47 | + else console.log("unexpected scheType", sche); | ||
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | connection.query(dateQueryString, [dateSchedules], (error, result) => { | 50 | connection.query(dateQueryString, [dateSchedules], (error, result) => { | ... | ... |
-
Please register or login to post a comment