diff --git a/CHANGELOG.md b/CHANGELOG.md index daa2af344..d393517df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Remove unused `getTimetableImage` function in `Export/GetImages.hs` - Refactored various backend text functions and tests to avoid `String` data in favour of `Text` when feasible - Removed unused files +- Removed `Location` datatype in favour of `Building` ## [0.7.2] - 2025-12-10 diff --git a/app/Database/Tables.hs b/app/Database/Tables.hs index 44026c8c2..c41d3ceed 100644 --- a/app/Database/Tables.hs +++ b/app/Database/Tables.hs @@ -180,8 +180,8 @@ data Time = Time { weekDay :: Double, startHour :: Double, endHour :: Double, - firstRoom :: Maybe Location, - secondRoom :: Maybe Location + firstRoom :: Maybe Building, + secondRoom :: Maybe Building } deriving (Show, Generic) data Location = @@ -323,8 +323,8 @@ convertTimeVals _ _ _ = (5.0, 25.0, 25.0) -- | Convert Times into Time buildTime :: Times -> SqlPersistM Time buildTime t = do - room1 <- buildLocation (timesFirstRoom t) - room2 <- buildLocation (timesSecondRoom t) + room1 <- getBuilding (timesFirstRoom t) + room2 <- getBuilding (timesSecondRoom t) return $ Time (timesWeekDay t) (timesStartHour t) (timesEndHour t) @@ -340,8 +340,9 @@ buildTimes meetingKey t = (firstRoom' t) (secondRoom' t) -buildLocation :: Maybe T.Text -> SqlPersistM (Maybe Location) -buildLocation rm = do +-- | Given a building code, get the persistent Building associated with it +getBuilding :: Maybe T.Text -> SqlPersistM (Maybe Building) +getBuilding rm = do case rm of Nothing -> return Nothing Just r -> do @@ -350,10 +351,4 @@ buildLocation rm = do Nothing -> return Nothing Just entBuilding -> do let building = entityVal entBuilding - return $ Just $ Location (T.take 2 r) -- Remove room number - (buildingName building) - (buildingCode building) - (buildingAddress building) - (buildingPostalCode building) - (buildingLat building) - (buildingLng building) + return $ Just building diff --git a/backend-test/Controllers/CourseControllerTests.hs b/backend-test/Controllers/CourseControllerTests.hs index fe5c87893..ed8b002f4 100644 --- a/backend-test/Controllers/CourseControllerTests.hs +++ b/backend-test/Controllers/CourseControllerTests.hs @@ -14,19 +14,22 @@ import Control.Monad (unless) import Controllers.Course (courseInfo, index, retrieveCourse) import qualified Data.ByteString.Lazy.Char8 as BL import qualified Data.Map as Map -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe, mapMaybe) +import Data.List (nub) import qualified Data.Text as T -import Database.Persist.Sqlite (SqlPersistM, insert_) -import Database.Tables (Courses (..)) +import Database.Persist.Sqlite (SqlPersistM, insert, insert_, insertMany_) +import Database.Tables (Building (..), Courses (..), MeetTime (..), Meeting (..), Time' (..), buildTimes) import Happstack.Server (rsBody, rsCode) import Test.Tasty (TestTree) import Test.Tasty.HUnit (assertEqual, testCase) import TestHelpers (clearDatabase, mockGetRequest, runServerPart, runServerPartWith, withDatabase) --- | List of test cases as (input course name, course data, status code, expected JSON output) -retrieveCourseTestCases :: [(String, T.Text, Map.Map T.Text T.Text, Int, String)] + +-- | List of test cases as (case description, input course name, course data, list of meeting data, status code, expected JSON output) +retrieveCourseTestCases :: [(String, T.Text, Map.Map T.Text T.Text, [MeetTime], Int, String)] retrieveCourseTestCases = - [ ("Course exists", + [ + ("Course exists with meeting times, and other meeting times exist", "STA238", Map.fromList [ ("name", "STA238H1"), @@ -40,6 +43,128 @@ retrieveCourseTestCases = ("coreqs", "CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance."), ("videoUrls", "https://example.com/video1, https://example.com/video2") ], + [ + MeetTime + Meeting { + meetingCode = "STA238", + meetingSession = "F", + meetingSection = "LEC0101", + meetingCap = 50, + meetingInstructor = "Instructor Name", + meetingEnrol = 15, + meetingWait = 0, + meetingExtra = 0 + } + [ + Time' { + weekDay' = 0.0, + startHour' = 10.0, + endHour' = 11.0, + firstRoom' = Just "MP", + secondRoom' = Nothing + }, + Time' { + weekDay' = 2.0, + startHour' = 13.0, + endHour' = 14.0, + firstRoom' = Just "SS", + secondRoom' = Nothing + } + ], + MeetTime + Meeting { + meetingCode = "STA239", + meetingSession = "S", + meetingSection = "LEC0201", + meetingCap = 500, + meetingInstructor = "Instructor Name 2", + meetingEnrol = 150, + meetingWait = 0, + meetingExtra = 0 + } + [ + Time' { + weekDay' = 1.0, + startHour' = 10.0, + endHour' = 11.0, + firstRoom' = Just "WW", + secondRoom' = Nothing + }, + Time' { + weekDay' = 4.0, + startHour' = 13.0, + endHour' = 14.0, + firstRoom' = Just "SS", + secondRoom' = Nothing + } + ] + ], + 200, + "{\"allMeetingTimes\":[{\"meetData\":{\"cap\":50,\"code\":\"STA238\",\"enrol\":15,\"extra\":0,\"instructor\":\"Instructor Name\",\"section\":\"LEC0101\",\"session\":\"F\",\"wait\":0},\"timeData\":[{\"endHour\":11,\"firstRoom\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"MP\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"MP\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondRoom\":null,\"startHour\":10,\"weekDay\":0},{\"endHour\":14,\"firstRoom\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"SS\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"SS\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondRoom\":null,\"startHour\":13,\"weekDay\":2}]}],\"breadth\":null,\"coreqs\":\"CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance.\",\"description\":\"An introduction to statistical inference and practice. Statistical models and parameters, estimators of parameters and their statistical properties, methods of estimation, confidence intervals, hypothesis testing, likelihood function, the linear model. Use of statistical computation for data analysis and simulation.\",\"distribution\":null,\"exclusions\":\"ECO220Y1/ ECO227Y1/ GGR270H1/ PSY201H1/ SOC300H1/ SOC202H1/ SOC252H1/ STA220H1/ STA221H1/ STA255H1/ STA248H1/ STA261H1/ STA288H1/ EEB225H1/ STAB22H3/ STAB27H3/ STAB57H3/ STA220H5/ STA221H5/ STA258H5/ STA260H5/ ECO220Y5/ ECO227Y5\",\"name\":\"STA238H1\",\"prereqString\":\"STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5\",\"title\":\"Probability, Statistics and Data Analysis II\",\"videoUrls\":[\"https://example.com/video1\",\"https://example.com/video2\"]}" + ), + + ("Course exists with meeting times", + "STA238", + Map.fromList [ + ("name", "STA238H1"), + ("title", "Probability, Statistics and Data Analysis II"), + ("description", "An introduction to statistical inference and practice. Statistical models and parameters, estimators of parameters and their statistical properties, methods of estimation, confidence intervals, hypothesis testing, likelihood function, the linear model. Use of statistical computation for data analysis and simulation."), + ("prereqs", "STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5"), + ("exclusions", "ECO220Y1/ ECO227Y1/ GGR270H1/ PSY201H1/ SOC300H1/ SOC202H1/ SOC252H1/ STA220H1/ STA221H1/ STA255H1/ STA248H1/ STA261H1/ STA288H1/ EEB225H1/ STAB22H3/ STAB27H3/ STAB57H3/ STA220H5/ STA221H5/ STA258H5/ STA260H5/ ECO220Y5/ ECO227Y5"), + ("breadth", "The Physical and Mathematical Universes (5)"), + ("distribution", "null"), + ("prereqString", "STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5"), + ("coreqs", "CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance."), + ("videoUrls", "https://example.com/video1, https://example.com/video2") + ], + [ + MeetTime + Meeting { + meetingCode = "STA238", + meetingSession = "F", + meetingSection = "LEC0101", + meetingCap = 50, + meetingInstructor = "Instructor Name", + meetingEnrol = 15, + meetingWait = 0, + meetingExtra = 0 + } + [ + Time' { + weekDay' = 0.0, + startHour' = 10.0, + endHour' = 11.0, + firstRoom' = Just "MP", + secondRoom' = Nothing + }, + Time' { + weekDay' = 2.0, + startHour' = 13.0, + endHour' = 14.0, + firstRoom' = Just "SS", + secondRoom' = Nothing + } + ] + ], + 200, + "{\"allMeetingTimes\":[{\"meetData\":{\"cap\":50,\"code\":\"STA238\",\"enrol\":15,\"extra\":0,\"instructor\":\"Instructor Name\",\"section\":\"LEC0101\",\"session\":\"F\",\"wait\":0},\"timeData\":[{\"endHour\":11,\"firstRoom\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"MP\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"MP\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondRoom\":null,\"startHour\":10,\"weekDay\":0},{\"endHour\":14,\"firstRoom\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"SS\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"SS\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondRoom\":null,\"startHour\":13,\"weekDay\":2}]}],\"breadth\":null,\"coreqs\":\"CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance.\",\"description\":\"An introduction to statistical inference and practice. Statistical models and parameters, estimators of parameters and their statistical properties, methods of estimation, confidence intervals, hypothesis testing, likelihood function, the linear model. Use of statistical computation for data analysis and simulation.\",\"distribution\":null,\"exclusions\":\"ECO220Y1/ ECO227Y1/ GGR270H1/ PSY201H1/ SOC300H1/ SOC202H1/ SOC252H1/ STA220H1/ STA221H1/ STA255H1/ STA248H1/ STA261H1/ STA288H1/ EEB225H1/ STAB22H3/ STAB27H3/ STAB57H3/ STA220H5/ STA221H5/ STA258H5/ STA260H5/ ECO220Y5/ ECO227Y5\",\"name\":\"STA238H1\",\"prereqString\":\"STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5\",\"title\":\"Probability, Statistics and Data Analysis II\",\"videoUrls\":[\"https://example.com/video1\",\"https://example.com/video2\"]}" + ), + + ("Course exists", + "STA238", + Map.fromList [ + ("name", "STA238H1"), + ("title", "Probability, Statistics and Data Analysis II"), + ("description", "An introduction to statistical inference and practice. Statistical models and parameters, estimators of parameters and their statistical properties, methods of estimation, confidence intervals, hypothesis testing, likelihood function, the linear model. Use of statistical computation for data analysis and simulation."), + ("prereqs", "STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5"), + ("exclusions", "ECO220Y1/ ECO227Y1/ GGR270H1/ PSY201H1/ SOC300H1/ SOC202H1/ SOC252H1/ STA220H1/ STA221H1/ STA255H1/ STA248H1/ STA261H1/ STA288H1/ EEB225H1/ STAB22H3/ STAB27H3/ STAB57H3/ STA220H5/ STA221H5/ STA258H5/ STA260H5/ ECO220Y5/ ECO227Y5"), + ("breadth", "The Physical and Mathematical Universes (5)"), + ("distribution", "null"), + ("prereqString", "STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5"), + ("coreqs", "CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance."), + ("videoUrls", "https://example.com/video1, https://example.com/video2") + ], + [], 200, "{\"allMeetingTimes\":[],\"breadth\":null,\"coreqs\":\"CSC108H1/ CSC110Y1/ CSC148H1 *Note: the corequisite may be completed either concurrently or in advance.\",\"description\":\"An introduction to statistical inference and practice. Statistical models and parameters, estimators of parameters and their statistical properties, methods of estimation, confidence intervals, hypothesis testing, likelihood function, the linear model. Use of statistical computation for data analysis and simulation.\",\"distribution\":null,\"exclusions\":\"ECO220Y1/ ECO227Y1/ GGR270H1/ PSY201H1/ SOC300H1/ SOC202H1/ SOC252H1/ STA220H1/ STA221H1/ STA255H1/ STA248H1/ STA261H1/ STA288H1/ EEB225H1/ STAB22H3/ STAB27H3/ STAB57H3/ STA220H5/ STA221H5/ STA258H5/ STA260H5/ ECO220Y5/ ECO227Y5\",\"name\":\"STA238H1\",\"prereqString\":\"STA237H1/ STA247H1/ STA257H1/ STAB52H3/ STA256H5\",\"title\":\"Probability, Statistics and Data Analysis II\",\"videoUrls\":[\"https://example.com/video1\",\"https://example.com/video2\"]}" ), @@ -47,6 +172,7 @@ retrieveCourseTestCases = ("Course does not exist", "STA238", Map.empty, + [], 404, "Course not found" ), @@ -54,14 +180,15 @@ retrieveCourseTestCases = ("No course provided", "", Map.empty, + [], 404, "Course not found" ) ] -- | Run a test case (case, input, expected status code, expected output) on the retrieveCourse function. -runRetrieveCourseTest :: String -> T.Text -> Map.Map T.Text T.Text -> Int -> String -> TestTree -runRetrieveCourseTest label courseName courseData expectedCode expectedBody = +runRetrieveCourseTest :: String -> T.Text -> Map.Map T.Text T.Text -> [MeetTime] -> Int -> String -> TestTree +runRetrieveCourseTest label courseName courseData meetingTimes expectedCode expectedBody = testCase label $ do let currCourseName = fromMaybe "" $ Map.lookup "name" courseData @@ -83,10 +210,16 @@ runRetrieveCourseTest label courseName courseData expectedCode expectedBody = , coursesVideoUrls = videoUrls } + let buildingCodes = getUniqueBuildings meetingTimes + runDb $ do clearDatabase unless (T.null currCourseName) $ insert_ courseToInsert + unless (null buildingCodes) $ + insertBuildings buildingCodes + unless (null meetingTimes) $ + insertMeetingTimes meetingTimes response <- runServerPartWith Controllers.Course.retrieveCourse $ mockGetRequest "/course" [("name", T.unpack courseName)] "" let statusCode = rsCode response @@ -97,7 +230,7 @@ runRetrieveCourseTest label courseName courseData expectedCode expectedBody = -- | Run all the retrieveCourse test cases runRetrieveCourseTests :: [TestTree] -runRetrieveCourseTests = map (\(label, courseName, courseData, expectedCode, expectedBody) -> runRetrieveCourseTest label courseName courseData expectedCode expectedBody) retrieveCourseTestCases +runRetrieveCourseTests = map (\(label, courseName, courseData, meetingTimes, expectedCode, expectedBody) -> runRetrieveCourseTest label courseName courseData meetingTimes expectedCode expectedBody) retrieveCourseTestCases -- | Helper function to insert courses into the database insertCourses :: [T.Text] -> SqlPersistM () @@ -105,6 +238,26 @@ insertCourses = mapM_ insertCourse where insertCourse code = insert_ (Courses code Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing []) +-- | Helper function to insert MeetTimes into the database +insertMeetingTimes :: [MeetTime] -> SqlPersistM () +insertMeetingTimes = mapM_ insertMeeting + where + insertMeeting (MeetTime meetingData meetingTime) = do + meetingKey <- insert meetingData + insertMany_ $ map (buildTimes meetingKey) meetingTime + +-- | Helper function to insert dummy buildings from a list of codes +insertBuildings :: [T.Text] -> SqlPersistM () +insertBuildings = mapM_ insertBuilding + where + insertBuilding code = insert_ Building {buildingCode = code, buildingName = code, buildingAddress = "N/A", buildingPostalCode = "A1A 1A1", buildingLat = 1.0, buildingLng = 1.0} + +-- | Helper function to get a list of unique firstRoom' and secondRoom' values involved in a MeetTime +getUniqueBuildings :: [MeetTime] -> [T.Text] +getUniqueBuildings = nub . concatMap getMeetBuildings + where + getMeetBuildings (MeetTime _ times') = mapMaybe firstRoom' times' ++ mapMaybe secondRoom' times' + -- | List of test cases as (label, input courses, expected output) indexTestCases :: [(String, [T.Text], String)] indexTestCases = diff --git a/backend-test/TestHelpers.hs b/backend-test/TestHelpers.hs index 4645008fe..559432001 100644 --- a/backend-test/TestHelpers.hs +++ b/backend-test/TestHelpers.hs @@ -98,8 +98,8 @@ clearDatabase :: SqlPersistM () clearDatabase = do deleteWhere ([] :: [Filter Department]) deleteWhere ([] :: [Filter Courses]) - deleteWhere ([] :: [Filter Meeting]) deleteWhere ([] :: [Filter Times]) + deleteWhere ([] :: [Filter Meeting]) deleteWhere ([] :: [Filter Breadth]) deleteWhere ([] :: [Filter Distribution]) deleteWhere ([] :: [Filter Database.Tables.Text]) diff --git a/js/components/common/__tests__/GetTable.test.js b/js/components/common/__tests__/GetTable.test.js index a368d734f..40f3e5261 100644 --- a/js/components/common/__tests__/GetTable.test.js +++ b/js/components/common/__tests__/GetTable.test.js @@ -26,13 +26,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: null, startHour: 15, @@ -51,7 +50,7 @@ describe("getTable", () => { availability: "31 of 69 available", waitList: "0 students", time: ["Tuesday 15 - 17"], - room: ["LM 158 "], + room: ["LM "], }, ] expect(actual).toEqual(expected) @@ -76,13 +75,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "15 King's College Circle", - bCode: "UC", - bName: "University College", - lat: 43.66287995, - lng: -79.395181775127, - postalCode: "M5S 3H7", - room: "UC 179", + buildingAddress: "15 King's College Circle", + buildingCode: "UC", + buildingName: "University College", + buildingLat: 43.66287995, + buildingLng: -79.395181775127, + buildingPostalCode: "M5S 3H7", }, secondRoom: null, startHour: 16, @@ -91,13 +89,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: null, startHour: 15, @@ -116,7 +113,7 @@ describe("getTable", () => { availability: "31 of 69 available", waitList: "0 students", time: ["Tuesday 15 - 17", "Thursday 16 - 17"], - room: ["LM 158 ", "UC 179 "], + room: ["LM ", "UC "], }, ] @@ -142,22 +139,20 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "UC 179", + buildingAddress: "15 King's College Circle", + buildingCode: "UC", + buildingName: "University College", + buildingLat: 43.66287995, + buildingLng: -79.395181775127, + buildingPostalCode: "M5S 3H7", }, startHour: 15, weekDay: 1, @@ -175,7 +170,7 @@ describe("getTable", () => { availability: "31 of 69 available", waitList: "0 students", time: ["Tuesday 15 - 17"], - room: ["LM 158, UC 179"], + room: ["LM, UC"], }, ] expect(actual).toEqual(expected) @@ -200,13 +195,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: null, startHour: 15, @@ -229,13 +223,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: null, startHour: 15, @@ -254,7 +247,7 @@ describe("getTable", () => { availability: "31 of 69 available", waitList: "0 students", time: ["Tuesday 15 - 17"], - room: ["LM 158 "], + room: ["LM "], }, { activity: "LEC2001", @@ -262,7 +255,7 @@ describe("getTable", () => { availability: "0 of 1 available", waitList: "0 students", time: ["Tuesday 15 - 17"], - room: ["LM 158 "], + room: ["LM "], }, ] expect(actual).toEqual(expected) @@ -308,13 +301,12 @@ describe("getTable", () => { { endHour: 17, firstRoom: { - address: "80 St. George Street", - bCode: "LM", - bName: "Lash Miller Chemical Laboratories", - lat: 43.66160185, - lng: -79.39841172598216, - postalCode: "M5S 3H6", - room: "LM 158", + buildingAddress: "80 St. George Street", + buildingCode: "LM", + buildingName: "Lash Miller Chemical Laboratories", + buildingLat: 43.66160185, + buildingLng: -79.39841172598216, + buildingPostalCode: "M5S 3H6", }, secondRoom: null, startHour: 15, @@ -333,7 +325,7 @@ describe("getTable", () => { availability: "31 of 69 available", waitList: "0 students", time: ["Tuesday 15 - 17"], - room: ["LM 158 "], + room: ["LM "], }, { activity: "TUT0301", diff --git a/js/components/common/react_modal.js.jsx b/js/components/common/react_modal.js.jsx index 180b961fd..ab72ccd6d 100644 --- a/js/components/common/react_modal.js.jsx +++ b/js/components/common/react_modal.js.jsx @@ -152,14 +152,14 @@ class CourseModal extends React.Component { if (occurrence.firstRoom === null || occurrence.firstRoom === undefined) { firstRoom = " " } else { - firstRoom = occurrence.firstRoom.room + firstRoom = occurrence.firstRoom.buildingCode } let secondRoom = "" if (occurrence.secondRoom === null || occurrence.secondRoom === undefined) { secondRoom = " " } else { - secondRoom = occurrence.secondRoom.room + secondRoom = occurrence.secondRoom.buildingCode } if ((firstRoom != " ") & (secondRoom != " ")) { @@ -483,7 +483,7 @@ class MapModal extends React.Component { // their course codes groupLecturesByBuilding(lecsByBuilding, lecture, roomNum) { const foundBuilding = lecsByBuilding.find( - b => b.buildingName === lecture[roomNum].bName + b => b.buildingName === lecture[roomNum].buildingName ) const timeframeData = { @@ -503,12 +503,12 @@ class MapModal extends React.Component { // if the building is not in the lecsByBuilding yet, add it into the array if (!foundBuilding) { lecsByBuilding.push({ - buildingName: lecture[roomNum].bName, - buildingCode: lecture[roomNum].bCode, - address: lecture[roomNum].address, - lat: lecture[roomNum].lat, - lng: lecture[roomNum].lng, - postalCode: lecture[roomNum].postalCode, + buildingName: lecture[roomNum].buildingName, + buildingCode: lecture[roomNum].buildingCode, + address: lecture[roomNum].buildingAddress, + lat: lecture[roomNum].buildingLat, + lng: lecture[roomNum].buildingLng, + postalCode: lecture[roomNum].buildingPostalCode, days: [dayData], }) } @@ -700,14 +700,12 @@ class DayBox extends React.Component { getRoomStr(lec, room, roomNum) { return ( - "Room" + + "Location" + (lec.fstRoom && lec.secRoom ? " " + roomNum : "") + ": " + - room.room + - ", " + - room.bName + + room.buildingName + " (" + - room.bCode + + room.buildingCode + ")" ) } @@ -875,8 +873,8 @@ class CampusMap extends React.Component { let colouredMarker const buildingInd = this.props.selectedLecTimeframes.findIndex( lec => - (lec.fstRoom && lec.fstRoom.bCode === building.buildingCode) || - (lec.secRoom && lec.secRoom.bCode === building.buildingCode) + (lec.fstRoom && lec.fstRoom.buildingCode === building.buildingCode) || + (lec.secRoom && lec.secRoom.buildingCode === building.buildingCode) ) colouredMarker = buildingInd == -1 ? blueMarker : redMarker