Refactor Building functions into Model#1715
Open
AngelsandDevsLOL wants to merge 4 commits into
Open
Conversation
38f70c3 to
6fbc319
Compare
Coverage Report for CI Build 0Coverage decreased (-0.01%) to 58.267%Details
Uncovered Changes
Coverage Regressions28 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Contributor
david-yz-liu
left a comment
There was a problem hiding this comment.
@AngelsandDevsLOL nice work. In addition to the inline comment I left, please take this opportunity to also add new tests for parseBuildings. This will involve creating tests that use the database, so is a nice extension of the previous testing work you've done.
| Just entBuilding -> return $ Just (entityVal entBuilding) | ||
|
|
||
| -- | Convert a Times record into a Time by resolving room codes to Buildings | ||
| buildTime :: Times -> SqlPersistM Time |
Contributor
There was a problem hiding this comment.
Leave buildTime and buildTimes in the Tables.hs module. You're correct that there's no Time model, which is something we can improve on later.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Moves Building-related functions out of
Database/Tables.hsandWebParsing/ArtSciParser.hsinto a newModels/Building.hs, following a similar pattern asModels/Course.hsandModels/Meeting.hs.buildingsCSV,parseBuildings,getBuildingsFromCSVare moved fromWebParsing/ArtSciParser.hs.getBuilding,buildTime, andbuildTimesare moved fromDatabase/Tables.hs.All imports using the functions were updated to find the corresponding functions in
Models/Building.hs. This includes the following files:Models/Meeting.hs,Controllers/Timetable.hs, andWebParsing/UtsgJsonParser.hs....
Screenshots of your changes (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
When I moved
getBuildingfromDatabase/Tables.hs, I noticed thatbuildTimeusedgetBuildingas a helper function. I wasn't sure whether I should movebuildTimetoModels/Building.hsas well because it seems more related to the Time datatype than the Building datatype. However, there was noModels/Time.hs, and by leaving the method inDatabase/Tables.hs, then usinggetBuildingwould need to import the method fromModels/Building.hs. However,Models/Building.hsmust importDatabase/Tables.hsbecause it needs to reference the Building datatype. Thus, I decided to movebuildTimeinsideModels/Building.hs, even though it feels a little bit weird.buildTimeswas moved along withbuildTime, because I thought it would be better to keep these two functions together. However, I think keeping it inDatabase/Tables.hsisn't a problem.