-
Notifications
You must be signed in to change notification settings - Fork 71
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
Paper-Manu #72
base: master
Are you sure you want to change the base?
Paper-Manu #72
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember, None
is falsey:
if goal == None: | |
if not goal: |
if goal == None: | ||
return "",404 | ||
|
||
# goal.completed_at = None |
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 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] |
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.
List comprehension! 😄
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to:
completed_at = self.completed_at | |
if completed_at == None: | |
is_complete = False | |
else: | |
is_complete = True | |
return is_complete | |
return self.completed_at != None |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on why you didn't use task.get_json
here.
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>
.
|
Updating all endpoints to pass all test Waves