-
Notifications
You must be signed in to change notification settings - Fork 111
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
Whales - Gaby Webb #110
base: master
Are you sure you want to change the base?
Whales - Gaby Webb #110
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.
Great job!
I noted a couple of small stylistic things but overall everything looks really solid.
Well done!
goal_dict = { | ||
"id": self.goal_id, | ||
"title": self.title, | ||
} | ||
return goal_dict |
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.
Since you immediately return this you don't need to assign it to a variable:
goal_dict = { | |
"id": self.goal_id, | |
"title": self.title, | |
} | |
return goal_dict | |
return { | |
"id": self.goal_id, | |
"title": self.title, | |
} |
task_dict = { | ||
"id": self.task_id, | ||
"title": self.title, | ||
"description": self.description | ||
} | ||
if self.completed_at is None: | ||
task_dict["is_complete"] = False | ||
else: | ||
task_dict["is_complete"] = True |
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:
task_dict = { | |
"id": self.task_id, | |
"title": self.title, | |
"description": self.description | |
} | |
if self.completed_at is None: | |
task_dict["is_complete"] = False | |
else: | |
task_dict["is_complete"] = True | |
task_dict = { | |
"id": self.task_id, | |
"title": self.title, | |
"description": self.description, | |
"is_complete": bool(self.completed_at) | |
} |
title = db.Column(db.String) | ||
tasks = db.relationship('Task', backref='goal', lazy=True) | ||
|
||
def create_goal_dict(self): |
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.
Style: Since this is a method on the Goal
class having goal
in the name is redundant:
def create_goal_dict(self): | |
def create_dict(self): |
return response | ||
|
||
def get_one_task_or_abort(task_id): |
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 like this helper function. It's really clearly named and clean. 😃
(You even have great error messages!)
} | ||
|
||
post_message = requests.post(path, data=data, headers=headers) |
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.
Style: Since you don't do anything with this variable it's a best practice not to store it:
post_message = requests.post(path, data=data, headers=headers) | |
requests.post(path, data=data, headers=headers) |
No description provided.