-
Notifications
You must be signed in to change notification settings - Fork 69
Refactoring the Graph Methods #1566
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
Refactoring the Graph Methods #1566
Conversation
Pull Request Test Coverage Report for Build 7d325cb3-a229-44a6-87a3-c0e37be35244Details
💛 - Coveralls |
app/Database/CourseInsertion.hs
Outdated
insertMany_ $ map (\text -> text {textGraph = gId}) texts | ||
insertMany_ $ map (\shape -> shape {shapeGraph = gId}) shapes | ||
insertMany_ $ map (\path -> path {pathGraph = gId}) paths | ||
-- Commented out function from before refactoring process to MVC |
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.
You can delete this comment
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.
@matt-dahlgren I think you missed this part of my last review (about deleting the comment in the source code). Please delete this before I merge in this PR (everything else looks great).
app/Models/Graph.hs
Outdated
return (Just response) | ||
|
||
-- | Inserts SVG graph data into Texts, Shapes, and Paths tables | ||
saveGraphJSON :: ServerPart Response |
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.
You did what I asked you to do, but now that I'm looking at the code more closely, I realized that the best approach was to actually to split up this function into two: saveGraphJSON
should go into the Controllers.Graph
module, while the main helper insertGraph
should go into here. This is the cleanest way to adhere to the MVC architecture: basically, any function with a ServerPart Response
type should really be a controller function, while the part that interacts with the database is categorized as a model.
By the way, while you're at it you can change the type of insertGraph
to insertGraph :: T.Text -> SvgJSON -> SqlPersistM ()
; that is, the components of the SvgJSON
don't need to be unpacked in the controller function, they can be unpacked in the model function only.
… into dahlgre4-refactor-graph Merging from main#
Proposed Changes
In the process of refactoring Courseography into a MVC architecture I Moved the
getGraph
(fromapp/Database/CourseQueries
) andgetGraphJSON
(fromapp/Controllers/Graph
) methods into a new moduleGraph.hs
withinapp/Models
. I also updated calls to these functions to reference the correct file and introduced the new module to thecourseography.cabal
file.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.)