Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/Database/Tables.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Times
startHour Double
endHour Double
meeting MeetingId
firstRoom T.Text Maybe
secondRoom T.Text Maybe
firstLocation T.Text Maybe
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not make changes directly to the table schema itself without making a migration. I think that's a bit larger of a task, so for now please revert changes to the Times data type (but you can keep changes to the Time and Time' data types).

secondLocation T.Text Maybe

Breadth
description T.Text
Expand Down Expand Up @@ -172,16 +172,16 @@ data Time' =
Time' { weekDay' :: Double,
startHour' :: Double,
endHour' :: Double,
firstRoom' :: Maybe T.Text,
secondRoom' :: Maybe T.Text
firstLocation' :: Maybe T.Text,
secondLocation' :: Maybe T.Text
} deriving (Show, Generic)

data Time =
Time { weekDay :: Double,
startHour :: Double,
endHour :: Double,
firstRoom :: Maybe Building,
secondRoom :: Maybe Building
firstLocation :: Maybe Building,
secondLocation :: Maybe Building
} deriving (Show, Generic)

-- | A Meeting with its associated Times.
Expand Down Expand Up @@ -312,8 +312,8 @@ convertTimeVals _ _ _ = (5.0, 25.0, 25.0)
-- | Convert Times into Time
buildTime :: Times -> SqlPersistM Time
buildTime t = do
room1 <- getBuilding (timesFirstRoom t)
room2 <- getBuilding (timesSecondRoom t)
room1 <- getBuilding (timesFirstLocation t)
room2 <- getBuilding (timesSecondLocation t)
return $ Time (timesWeekDay t)
(timesStartHour t)
(timesEndHour t)
Expand All @@ -326,8 +326,8 @@ buildTimes meetingKey t =
(startHour' t)
(endHour' t)
meetingKey
(firstRoom' t)
(secondRoom' t)
(firstLocation' t)
(secondLocation' t)

-- | Given a building code, get the persistent Building associated with it
getBuilding :: Maybe T.Text -> SqlPersistM (Maybe Building)
Expand Down
32 changes: 16 additions & 16 deletions backend-test/Controllers/CourseControllerTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ retrieveCourseTestCases =
weekDay' = 0.0,
startHour' = 10.0,
endHour' = 11.0,
firstRoom' = Just "MP",
secondRoom' = Nothing
firstLocation' = Just "MP",
secondLocation' = Nothing
},
Time' {
weekDay' = 2.0,
startHour' = 13.0,
endHour' = 14.0,
firstRoom' = Just "SS",
secondRoom' = Nothing
firstLocation' = Just "SS",
secondLocation' = Nothing
}
],
MeetTime
Expand All @@ -88,20 +88,20 @@ retrieveCourseTestCases =
weekDay' = 1.0,
startHour' = 10.0,
endHour' = 11.0,
firstRoom' = Just "WW",
secondRoom' = Nothing
firstLocation' = Just "WW",
secondLocation' = Nothing
},
Time' {
weekDay' = 4.0,
startHour' = 13.0,
endHour' = 14.0,
firstRoom' = Just "SS",
secondRoom' = Nothing
firstLocation' = Just "SS",
secondLocation' = 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\"]}"
"{\"allMeetingTimes\":[{\"meetData\":{\"cap\":50,\"code\":\"STA238\",\"enrol\":15,\"extra\":0,\"instructor\":\"Instructor Name\",\"section\":\"LEC0101\",\"session\":\"F\",\"wait\":0},\"timeData\":[{\"endHour\":11,\"firstLocation\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"MP\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"MP\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondLocation\":null,\"startHour\":10,\"weekDay\":0},{\"endHour\":14,\"firstLocation\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"SS\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"SS\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondLocation\":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",
Expand Down Expand Up @@ -135,20 +135,20 @@ retrieveCourseTestCases =
weekDay' = 0.0,
startHour' = 10.0,
endHour' = 11.0,
firstRoom' = Just "MP",
secondRoom' = Nothing
firstLocation' = Just "MP",
secondLocation' = Nothing
},
Time' {
weekDay' = 2.0,
startHour' = 13.0,
endHour' = 14.0,
firstRoom' = Just "SS",
secondRoom' = Nothing
firstLocation' = Just "SS",
secondLocation' = 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\"]}"
"{\"allMeetingTimes\":[{\"meetData\":{\"cap\":50,\"code\":\"STA238\",\"enrol\":15,\"extra\":0,\"instructor\":\"Instructor Name\",\"section\":\"LEC0101\",\"session\":\"F\",\"wait\":0},\"timeData\":[{\"endHour\":11,\"firstLocation\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"MP\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"MP\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondLocation\":null,\"startHour\":10,\"weekDay\":0},{\"endHour\":14,\"firstLocation\":{\"buildingAddress\":\"N/A\",\"buildingCode\":\"SS\",\"buildingLat\":1,\"buildingLng\":1,\"buildingName\":\"SS\",\"buildingPostalCode\":\"A1A 1A1\"},\"secondLocation\":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",
Expand Down Expand Up @@ -253,11 +253,11 @@ 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
-- | Helper function to get a list of unique firstLocation' and secondLocation' values involved in a MeetTime
getUniqueBuildings :: [MeetTime] -> [T.Text]
getUniqueBuildings = nub . concatMap getMeetBuildings
where
getMeetBuildings (MeetTime _ times') = mapMaybe firstRoom' times' ++ mapMaybe secondRoom' times'
getMeetBuildings (MeetTime _ times') = mapMaybe firstLocation' times' ++ mapMaybe secondLocation' times'

-- | List of test cases as (label, input courses, expected output)
indexTestCases :: [(String, [T.Text], String)]
Expand Down
50 changes: 25 additions & 25 deletions js/components/common/__tests__/GetTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: null,
secondLocation: null,
startHour: 15,
weekDay: 1,
},
Expand All @@ -50,7 +50,7 @@ describe("getTable", () => {
availability: "31 of 69 available",
waitList: "0 students",
time: ["Tuesday 15 - 17"],
room: ["LM "],
location: ["LM "],
},
]
expect(actual).toEqual(expected)
Expand All @@ -74,29 +74,29 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "15 King's College Circle",
buildingCode: "UC",
buildingName: "University College",
buildingLat: 43.66287995,
buildingLng: -79.395181775127,
buildingPostalCode: "M5S 3H7",
},
secondRoom: null,
secondLocation: null,
startHour: 16,
weekDay: 3,
},
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: null,
secondLocation: null,
startHour: 15,
weekDay: 1,
},
Expand All @@ -113,15 +113,15 @@ describe("getTable", () => {
availability: "31 of 69 available",
waitList: "0 students",
time: ["Tuesday 15 - 17", "Thursday 16 - 17"],
room: ["LM ", "UC "],
location: ["LM ", "UC "],
},
]

expect(actual).toEqual(expected)
})
})

describe("The occurence of the lecture has two rooms ", () => {
describe("The occurence of the lecture has two locations ", () => {
beforeEach(() => {
meetingTime = [
{
Expand All @@ -138,15 +138,15 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: {
secondLocation: {
buildingAddress: "15 King's College Circle",
buildingCode: "UC",
buildingName: "University College",
Expand All @@ -161,7 +161,7 @@ describe("getTable", () => {
},
]
})
test("Both of the first and second room of the occurence are shown", () => {
test("Both of the first and second location of the occurence are shown", () => {
actual = wrapper.getTable(meetingTime, "F")
expected = [
{
Expand All @@ -170,7 +170,7 @@ describe("getTable", () => {
availability: "31 of 69 available",
waitList: "0 students",
time: ["Tuesday 15 - 17"],
room: ["LM, UC"],
location: ["LM, UC"],
},
]
expect(actual).toEqual(expected)
Expand All @@ -194,15 +194,15 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: null,
secondLocation: null,
startHour: 15,
weekDay: 1,
},
Expand All @@ -222,15 +222,15 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: null,
secondLocation: null,
startHour: 15,
weekDay: 1,
},
Expand All @@ -247,15 +247,15 @@ describe("getTable", () => {
availability: "31 of 69 available",
waitList: "0 students",
time: ["Tuesday 15 - 17"],
room: ["LM "],
location: ["LM "],
},
{
activity: "LEC2001",
instructor: "A. Jacobson",
availability: "0 of 1 available",
waitList: "0 students",
time: ["Tuesday 15 - 17"],
room: ["LM "],
location: ["LM "],
},
]
expect(actual).toEqual(expected)
Expand All @@ -279,8 +279,8 @@ describe("getTable", () => {
timeData: [
{
endHour: 16,
firstRoom: null,
secondRoom: null,
firstLocation: null,
secondLocation: null,
startHour: 14,
weekDay: 0,
},
Expand All @@ -300,15 +300,15 @@ describe("getTable", () => {
timeData: [
{
endHour: 17,
firstRoom: {
firstLocation: {
buildingAddress: "80 St. George Street",
buildingCode: "LM",
buildingName: "Lash Miller Chemical Laboratories",
buildingLat: 43.66160185,
buildingLng: -79.39841172598216,
buildingPostalCode: "M5S 3H6",
},
secondRoom: null,
secondLocation: null,
startHour: 15,
weekDay: 1,
},
Expand All @@ -325,15 +325,15 @@ describe("getTable", () => {
availability: "31 of 69 available",
waitList: "0 students",
time: ["Tuesday 15 - 17"],
room: ["LM "],
location: ["LM "],
},
{
activity: "TUT0301",
instructor: "Paul G.",
availability: "2 of 166 available",
waitList: "0 students",
time: ["Monday 14 - 16"],
room: [" "],
location: [" "],
},
]
expect(actual).toEqual(expected)
Expand Down
Loading