-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor route functionality into Controllers #1410
Conversation
…nbounded to bounded) Firstly, Controllers.Course now only defines the main functions that define the actual response functionality. All the helper methods on which these main methods depend has been moved back to and used with bounded imports. Secondly, in Controllers.Course and in Database.CourseQueries I refactored the import code to ensure that only bounded imports are used, explicitly specifying the desired identifiers.”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mimischly7 and @is-ahmed good work. I left a few comments to work on.
applying the professor's comments, including aliasing for imports, changing routes in all places, and returning ServerPart Response instead of IO Response in controller functions
app/Routes.hs
Outdated
@@ -3,13 +3,41 @@ module Routes | |||
|
|||
import Control.Monad (MonadPlus (mplus), msum) | |||
import Control.Monad.IO.Class (liftIO) | |||
import Controllers.Course as CourseControllers (retrieveCourse, index, courseInfo, depts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I guess I didn't pick up on this on your clarifying comment, but this should be CoursesController
the entity name is pluralized, not "controller". Same with the graph controller below.
app/Routes.hs
Outdated
("image", look "JsonLocalStorageObj" >>= graphImageResponse), | ||
("timetable-image", lookText' "session" >>= \session -> look "courses" >>= exportTimetableImageResponse session), | ||
("timetable-pdf", look "courses" >>= \courses -> look "JsonLocalStorageObj" >>= exportTimetablePDFResponse courses), | ||
("timetable-pdf", look "courses" >>= \coursesList -> look "JsonLocalStorageObj" >>= exportTimetablePDFResponse coursesList), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should no longer be necessary now that you're using the aliased import
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
Based on the initiative to adapt a more MVC architecture for Courseougraphy, we (with @is-ahmed) moved the functionality of graph-related and course-related routes to the (new)
Controllers.Graph
andControllers.Course
modules.Also, we changed imports in
Routes.hs
,Controllers/*.hs
, andDatabase.CourseQueries.hs
to ensure:Finally, some route and controller-function names (in particular for plural routes) have been changed to more closely abide by
Rails
naming conventions.Screenshots of your changes (if applicable)
Type of Change
(Write an
X
or 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
(Include any questions or comments you have regarding your changes.)