Open
Conversation
kaidamasaki
reviewed
Jun 27, 2022
kaidamasaki
left a comment
There was a problem hiding this comment.
Great job!
I noted a couple of small stylistic things but overall everything looks really solid.
Well done!
Comment on lines
+10
to
+14
| goal_dict = { | ||
| "id": self.goal_id, | ||
| "title": self.title, | ||
| } | ||
| return goal_dict |
There was a problem hiding this comment.
Since you immediately return this you don't need to assign it to a variable:
Suggested change
| goal_dict = { | |
| "id": self.goal_id, | |
| "title": self.title, | |
| } | |
| return goal_dict | |
| return { | |
| "id": self.goal_id, | |
| "title": self.title, | |
| } |
Comment on lines
+11
to
+19
| 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.
This can be simplified to:
Suggested change
| 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.
Style: Since this is a method on the Goal class having goal in the name is redundant:
Suggested change
| 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.
I like this helper function. It's really clearly named and clean. 😃
(You even have great error messages!)
| "authorization": "Bearer " + os.environ.get("SLACKBOT_API_KEY") | ||
| } | ||
|
|
||
| post_message = requests.post(path, data=data, headers=headers) |
There was a problem hiding this comment.
Style: Since you don't do anything with this variable it's a best practice not to store it:
Suggested change
| post_message = requests.post(path, data=data, headers=headers) | |
| requests.post(path, data=data, headers=headers) |
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.