Open
Conversation
kaidamasaki
reviewed
May 21, 2021
kaidamasaki
left a comment
There was a problem hiding this comment.
Good job!
I like that you split your routes file into goal_routes.py and task_routes.py. 😄
There were a few small things but overall everything looked great! Well done!
| def handle_goal(goal_id): | ||
| goal = Goal.query.get(goal_id) | ||
|
|
||
| if goal == None: |
There was a problem hiding this comment.
Remember, None is falsey:
Suggested change
| if goal == None: | |
| if not goal: |
| if goal == None: | ||
| return "",404 | ||
|
|
||
| # goal.completed_at = None |
There was a problem hiding this comment.
This is a minor thing but it's an industry best practice to remove commented in code before you submit a PR so is a good habit to get into. 😄
| return { | ||
| "id": goal.goal_id, | ||
| "title": goal.title, | ||
| "tasks": [task.get_json() for task in goal.tasks] |
Comment on lines
+16
to
+21
| completed_at = self.completed_at | ||
| if completed_at == None: | ||
| is_complete = False | ||
| else: | ||
| is_complete = True | ||
| return is_complete |
There was a problem hiding this comment.
This can be simplified to:
Suggested change
| completed_at = self.completed_at | |
| if completed_at == None: | |
| is_complete = False | |
| else: | |
| is_complete = True | |
| return is_complete | |
| return self.completed_at != None |
Comment on lines
+20
to
+30
| if task.completed_at == None: | ||
| completed_at = False | ||
| else: | ||
| completed_at = True | ||
|
|
||
| tasks_response.append({ | ||
| "id": task.task_id, | ||
| "title": task.title, | ||
| "description": task.description, | ||
| "is_complete": completed_at | ||
| }) |
There was a problem hiding this comment.
I'm not clear on why you didn't use task.get_json here.
Author
|
Aloha Kaida,
Thank you for the feedback. I will apply the changes in due time. This
feedback is so helpful. I know I didn't have the time to dry up the code,
but turned it in when I absolutely could once I passed all the tests.
I had a slow start with establishing workflow and deciphering the
directions. Perhaps next project, if possible, may I plan to set some
private time to do setup and establish workflow? Per my learning
disability, I am still troubleshooting and trying to be creative with being
more efficient in the start of the projects. Any direction or guidance
would be greatly appreciated. I do love it once I get it, but it seems a
lot of time goes into deciphering. These projects are interesting and fun,
once it all "clicks." Thank you.
Mahalo,
Manu Ponce
…On Fri, May 21, 2021 at 11:23 AM Kaida Masaki ***@***.***> wrote:
***@***.**** commented on this pull request.
Good job!
I like that you split your routes file into goal_routes.py and
task_routes.py. 😄
There were a few small things but overall everything looked great! Well
done!
------------------------------
In app/goal_routes.py
<#72 (comment)>:
> + db.session.add(goal)
+ db.session.commit()
+
+ return {
+ "goal": {
+ "id": goal.goal_id,
+ "title": goal.title
+ }
+ }, 201
+
+#get 1 goal
***@***.***_bp.route("/<goal_id>", methods=["GET", "PUT", "DELETE"])
+def handle_goal(goal_id):
+ goal = Goal.query.get(goal_id)
+
+ if goal == None:
Remember, None is falsey:
⬇️ Suggested change
- if goal == None:
+ if not goal:
------------------------------
In app/goal_routes.py
<#72 (comment)>:
> +
+ return {
+ "goal": {
+ "id": goal.goal_id,
+ "title": "Updated Goal Title"
+ }
+ }
+
***@***.***_bp.route("/<goal_id>/mark_incomplete", methods=["PATCH"])
+def mark_incomplete(goal_id):
+ goal = Goal.query.get(goal_id)
+
+ if goal == None:
+ return "",404
+
+ # goal.completed_at = None
This is a minor thing but it's an industry best practice to remove
commented in code before you submit a PR so is a good habit to get into.
😄
------------------------------
In app/goal_routes.py
<#72 (comment)>:
> + "goal": {
+ "id": goal.goal_id,
+ "title": goal.title
+ }
+ }
+
***@***.***_bp.route("/<int:id>/tasks", methods=["GET", "POST"])
+def tasks_and_goal(id):
+ if request.method == "GET":
+ goal = Goal.query.get(id)
+ if not goal:
+ return make_response("Goal does\'t exist", 404)
+ return {
+ "id": goal.goal_id,
+ "title": goal.title,
+ "tasks": [task.get_json() for task in goal.tasks]
List comprehension! 😄
------------------------------
In app/models/task.py
<#72 (comment)>:
> + completed_at = self.completed_at
+ if completed_at == None:
+ is_complete = False
+ else:
+ is_complete = True
+ return is_complete
This can be simplified to:
⬇️ Suggested change
- completed_at = self.completed_at
- if completed_at == None:
- is_complete = False
- else:
- is_complete = True
- return is_complete
+ return self.completed_at != None
------------------------------
In app/routes.py
<#72 (comment)>:
> + if task.completed_at == None:
+ completed_at = False
+ else:
+ completed_at = True
+
+ tasks_response.append({
+ "id": task.task_id,
+ "title": task.title,
+ "description": task.description,
+ "is_complete": completed_at
+ })
I'm not clear on why you didn't use task.get_json here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#72 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ6AUFCBI5P2ZFSQC2WPWCTTO2QLLANCNFSM445AASXA>
.
|
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.
Updating all endpoints to pass all test Waves