Skip to content
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

Pine - Lety #70

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Pine - Lety #70

wants to merge 7 commits into from

Conversation

letypl12
Copy link

@letypl12 letypl12 commented Nov 5, 2021

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

I strongly suggest that you describe functionality added when you make commit messages. Your commit messages mostly describe tests passed etc. Just describe what the code you wrote does. Also try to make small granular commits, maybe do one function and then add and commit.

Otherwise this is quite well done. I left some minor feedback. Let me know if you have any questions.

__tablename__ = 'goal'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String)
#these are not just IDs, like a list of numbers...they are objects of type Task

Choose a reason for hiding this comment

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

True!

Comment on lines +12 to +28
def to_dict(self):
return {
"id": self.id,
"title": self.title,
}


def goal_tasks_to_dict(self):
mytasks = Task.query.all(self[0].tasks)
mylist = []
for thing in mytasks:
mylist.append(thing.id)

return {
"id": self.id,
"task_ids": mylist
}

Choose a reason for hiding this comment

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

I feel like these could be combined.

completed_at = db.Column(db.DateTime, nullable=True)
goal_id = db.Column(db.Integer, db.ForeignKey("goal.id"), nullable=True)

def to_dict(self):

Choose a reason for hiding this comment

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

👍 Nice helper method

from dotenv import load_dotenv
import os

load_dotenv()

Choose a reason for hiding this comment

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

I think the load_dotenv() function has been run in the app/__init__.py file

Comment on lines +28 to +31
if request_body['completed_at'] == None:
return make_response({"task":new_task.to_dict()}), 201
else:
return make_response({"task":new_task.to_dict()}), 201

Choose a reason for hiding this comment

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

I'm not sure what the point of this if-else block is?

my_task = Task.query.get(task_id)
if request.method == "GET":
if my_task is None:
return "", 404

Choose a reason for hiding this comment

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

This is mostly a chris-ism, but I prefer having a meaningful message in the response body in addition to responding with the response code.

else:
if completed_status == "mark_complete":
my_task.completed_at = datetime.now()
send_slack_notice(my_task.title)

Choose a reason for hiding this comment

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

I love the fact that you use a helper function here.

if request.method == "POST":
request_body = request.get_json()
if "title" not in request_body:
return {"details": "Invalid data"}, 400

Choose a reason for hiding this comment

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

Maybe respond with more detail, like

Suggested change
return {"details": "Invalid data"}, 400
return {"details": "'title' is required"}, 400

@@ -1,4 +1,5 @@
import pytest
from app.models.goal import Goal

Choose a reason for hiding this comment

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

Nice work on the tests!

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