Skip to content

Conversation

@raeelwell
Copy link

No description provided.

Copy link

@kaidamasaki kaidamasaki left a 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!

Comment on lines +14 to +17
response_body = jsonify({"goal" : {
"id": self.get_id(),
"title": self.title,
}}), response_code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: indentation.

Suggested change
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

Comment on lines +22 to +29
# 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:

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)

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:

Suggested change
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.)

Comment on lines +30 to +35
def model_select(url):
if "goals" in url:
mdl = Goal
else:
mdl = Task
return mdl

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants