Conversation
…r function to eliminate redundancy
…le in ascending and descending order
…nd incomplete, added a function in routes which takes in both task number and complete/incomplete as variable and routes to helper functions
… need to DRY and finish up the conversion from task to goal
…ry functions to deal with new situaitons
…hon files and created a helper function for routes to validate the models to eliminate redundency in task and goal models
CheezItMan
reviewed
Dec 4, 2022
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Violet, you hit the learning goals here. I left some minor comments in the code. If you have questions let me know via Slack.
Comment on lines
+31
to
+35
| if sort_query: | ||
| sort_function = getattr(sqlalchemy, sort_query) | ||
| goal_list = Goal.query.order_by(sort_function(Goal.title)) | ||
| else: | ||
| goal_list = Goal.query.all() |
Comment on lines
+43
to
+44
| @goal_bp.route("random", methods=["GET"]) | ||
| def get_random_goal(): |
Comment on lines
+31
to
+32
| @classmethod | ||
| def from_dict(cls, request_body): |
|
|
||
|
|
||
|
|
||
| def validate_model_id(cls, id): |
There was a problem hiding this comment.
Nice helper function. It would be good to have another to validate required fields in the request body.
Comment on lines
+62
to
+63
| task.title = request_body["title"] | ||
| task.description = request_body["description"] |
Comment on lines
+18
to
+19
| request_body = request.get_json() | ||
| new_task = Task.from_dict(request_body) |
There was a problem hiding this comment.
There doesn't seem to be any validation to check to see if the request body has a title or description.
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.
No description provided.