Skip to content

Commit a4955e8

Browse files
committed
Fallback for missing Departments and 0 Errors
1 parent 2e74aef commit a4955e8

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

schema/migrationScripts/3.0.30.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ COMMENT 'current enrollment',
1010
CHANGE `instructor` `instructor` VARCHAR(64) NOT NULL DEFAULT 'TBA'
1111
COMMENT 'Instructor\'s Name';
1212

13-
UPDATE `sections` SET `type`='OL' WHERE `type`='O';
13+
UPDATE `sections`
14+
SET `type` = 'OL'
15+
WHERE `type` = 'O';
1416

1517
ALTER TABLE `sections`
1618
CHANGE `type` `type` ENUM ('R', 'N', 'H', 'BL', 'OL')
@@ -26,4 +28,11 @@ COMMENT 'room number';
2628

2729
INSERT INTO `buildings` (`number`, `code`, `name`) VALUES ('ZAG', 'ZAG', 'Building in Croatia');
2830

29-
ALTER TABLE `quarters` DROP `breakstart`, DROP `breakend`;
31+
ALTER TABLE `quarters`
32+
DROP `breakstart`,
33+
DROP `breakend`;
34+
35+
ALTER TABLE `departments`
36+
CHANGE `title` `title` VARCHAR(30)
37+
CHARACTER SET latin1
38+
COLLATE latin1_swedish_ci NULL;

tools/processDump.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,31 @@ function halt($messages) {
8080
* Inserts or updates a course. This function calls the stored procedure for
8181
* inserting or updating a course.
8282
* @param $quarter int The term that the course is in
83-
* @param $departNum int The number of the department
84-
* @param $departCode int The code for the department
83+
* @param $departCode String The code of the department
84+
* @param $classCode String The code for the class
8585
* @param $course int The number of the course
8686
* @param $credits int The credits the course offers
8787
* @param $title String The title of the course
8888
* @param $description String The description for the course
8989
* @return mixed String of error message returned on failure.
9090
* Integer of course ID returned on success
9191
*/
92-
function insertOrUpdateCourse($quarter, $departNum, $departCode, $course, $credits, $title, $description) {
92+
function insertOrUpdateCourse($quarter, $departCode, $classCode, $course, $credits, $title, $description) {
9393
global $dbConn, $coursesUpdated, $coursesAdded;
9494
// Call the stored proc
95-
$query = "CALL InsertOrUpdateCourse({$quarter}, {$departNum}, '{$departCode}', '{$course}', {$credits}, '{$title}', '{$description}')";
95+
// TODO: Refactor out department ID number (0000)
96+
$query = "CALL InsertOrUpdateCourse({$quarter}, 0000, '{$classCode}', '{$course}', {$credits}, '{$title}', '{$description}')";
9697
$success = mysqli_multi_query($dbConn, $query);
9798

9899
// Catch errors or return the id
99100
if(!$success) {
100-
return mysqli_error($dbConn);
101+
// If the class code errors out, try the department code
102+
// TODO: Refactor out department ID number (0000)
103+
$query = "CALL InsertOrUpdateCourse({$quarter}, 0000, '{$departCode}', '{$course}', {$credits}, '{$title}', '{$description}')";
104+
$success = mysqli_multi_query($dbConn, $query);
105+
if(!$success) {
106+
return mysqli_error($dbConn);
107+
}
101108
}
102109

103110
// First result set is updated vs inserted
@@ -558,10 +565,10 @@ function procInstrArray($lineSplit) {
558565
$row['course_descrlong'] = mysqli_real_escape_string($dbConn, $row['course_descrlong']);
559566

560567
// Insert or update the course
561-
$courseId = insertOrUpdateCourse($row['qtr'], 0000, $row['acad_org'], $row['catalog_nbr'],
568+
$courseId = insertOrUpdateCourse($row['qtr'], $row['acad_org'], $row['subject'], $row['catalog_nbr'],
562569
$row['units'], $row['descr'], $row['course_descrlong']);
563-
if(!is_numeric($courseId)) {
564-
echo(" *** Error: Failed to update {$row['qtr']} {$row['subject']}{$row['acad_org']}-{$row['catalog_nbr']}\n");
570+
if (!is_numeric($courseId)) {
571+
echo(" *** Error: Failed to update {$row['qtr']} {$row['subject']}-{$row['catalog_nbr']}\n");
565572
echo(" ");
566573
var_dump($courseId);
567574
echo("\n");

0 commit comments

Comments
 (0)