-
Notifications
You must be signed in to change notification settings - Fork 97
Pull Request #87
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
base: master
Are you sure you want to change the base?
Pull Request #87
Conversation
kaidamasaki
left a comment
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!
One thing you should focus on is readability, especially with things like indenting your dictionaries.
Other than that your code looks quite good! (Though you should make sure that if you do something clever like with select_model and you're working with a partner you comment it enough for them to understand.)
Well done!
| response_body = jsonify({"goal" : { | ||
| "id": self.get_id(), | ||
| "title": self.title, | ||
| }}), response_code |
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: indentation.
| response_body = jsonify({"goal" : { | |
| "id": self.get_id(), | |
| "title": self.title, | |
| }}), response_code | |
| response_body = jsonify({"goal" : { | |
| "id": self.get_id(), | |
| "title": self.title, | |
| }}), response_code |
| # try: response_body = jsonify({"task" : { | ||
| # "id": self.get_id(), | ||
| # "goal_id": self.goal_id, | ||
| # "title": self.title, | ||
| # "description": self.description, | ||
| # "is_complete": self.is_complete(), | ||
| # }}) | ||
| # except AttributeError: |
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: clean up commented out code.
| try: | ||
| int(number) | ||
| except: | ||
| return make_response(f"{number} is not an int!", 400) |
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 cleaner if you just use abort:
| return make_response(f"{number} is not an int!", 400) | |
| abort(make_response(f"{number} is not an int!", 400)) |
(abort raises a special exception that results in a response being sent back immediately.)
| def model_select(url): | ||
| if "goals" in url: | ||
| mdl = Goal | ||
| else: | ||
| mdl = Task | ||
| return mdl |
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 bordering on too clever but does really DRY your code up!
(By too clever I mean it might be hard to debug/understand.)
| task = Task.query.get(task_id) | ||
| task.completed_at = datetime.now(timezone.utc) | ||
| db.session.commit() | ||
| print(response.text) |
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: clean up debugging print calls.
No description provided.