Skip to content
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

Merged
merged 23 commits into from
May 31, 2024

Conversation

mimischly7
Copy link
Contributor

@mimischly7 mimischly7 commented May 17, 2024

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 and Controllers.Course modules.

Also, we changed imports in Routes.hs, Controllers/*.hs, and Database.CourseQueries.hs to ensure:

  • explicit naming of the needed identifiers (in order to move away from unbounded imports, which raise ambiguity when trying to understand where something comes from)
  • that only necessary imports are included (there are no redundant imports)

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) Screenshot 2024-05-17 at 10 28 37 AM

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality) X
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

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:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.
  • I have updated the project Changelog (this is required for all changes).

After opening your pull request:

  • I have verified that the CircleCI checks have passed.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@mimischly7 mimischly7 changed the title Task 1 Refactor route functionality into Controllers May 17, 2024
mimischly7 and others added 6 commits May 17, 2024 12:44
…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.”
@mimischly7 mimischly7 marked this pull request as ready for review May 20, 2024 19:58
Copy link
Contributor

@david-yz-liu david-yz-liu left a 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.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
app/Routes.hs Outdated Show resolved Hide resolved
app/Response/Graph.hs Outdated Show resolved Hide resolved
app/Controllers/Course.hs Outdated Show resolved Hide resolved
app/Database/CourseQueries.hs Outdated Show resolved Hide resolved
app/Routes.hs Outdated Show resolved Hide resolved
is-ahmed and others added 4 commits May 22, 2024 08:34
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
CHANGELOG.md Outdated Show resolved Hide resolved
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)
Copy link
Contributor

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),
Copy link
Contributor

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

@david-yz-liu david-yz-liu merged commit 74e5c39 into Courseography:master May 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants