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

Scissors_Gloria #73

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

Scissors_Gloria #73

wants to merge 16 commits into from

Conversation

ggrossvi
Copy link

No description provided.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Good work on your first Flask project. Your code is clear and meets nearly all the requirements. We can talk through getting those final few tests passing. I've left inline comments mainly focused on ways to use instance methods to DRY up the code. I look forward to talking through it together!

# }
# return result

def notify_slack(self):

Choose a reason for hiding this comment

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

Great work encapsulating this functionality in a instance method.

}
return result

# def serialize_two(self):

Choose a reason for hiding this comment

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

You're on the right track with this alternative helper instance method! What we need is to use serialize when goal_id is None (the task doesn't belong to a goal), and serialize_two when goal_id is a truthy value (the task does belong to a goal)

app/routes.py Outdated
goal_response = []
for goal in goals:
goal_response.append({
'id': goal.goal_id,

Choose a reason for hiding this comment

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

You could use goal.serialize() here to DRY up your code.

app/routes.py Outdated
'title': task.title,
'description': task.description,
'is_complete': task.completed_at != None,
'goal_id': task.goal_id

Choose a reason for hiding this comment

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

Per my comment in the task.py model, this is where we need to conditionally include goal_id depending on whether it's None or an int value.

app/routes.py Outdated
Comment on lines 118 to 123
arg = request.args
if "sort" in request.args:
if arg['sort'] == "asc":
task_response = sorted(task_response, key = order_by_title)
elif arg['sort'] == "desc":
task_response = sorted(task_response, key = order_by_title, reverse = True)

Choose a reason for hiding this comment

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

Minor note: it would be good to move this logic about the initial query for tasks, so that if we do have a sort query parameter we don't first build an unsorted list of tasks and then overwrite it.

Comment on lines +128 to +139
if "title" not in request_body:
return {
"details": "Invalid data"
}, 400
elif "description" not in request_body:
return {
"details": "Invalid data"
}, 400
elif "completed_at" 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.

We could combine this in a compound conditional statement to DRY up the code:

if "title not in request_body or "description not in request body or "completed_at" not in request_body: 
       return {"details": "Invalid data"}, 400

'id': new_task.task_id,
'title': new_task.title,
'description': new_task.description,
'is_complete': new_task.completed_at != None

Choose a reason for hiding this comment

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

Consider moving the logic to convert completed_at to a True or False value into an instance method and use the serialize instance method here.

Comment on lines +206 to +211
'task':{
'id': task.task_id,
'title': task.title,
'description': task.description,
'is_complete': task.completed_at != None
}

Choose a reason for hiding this comment

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

Notice that this code is repeated below. This is a great place to use an instance method.

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