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

C17/Bahareh/Sharks #108

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

C17/Bahareh/Sharks #108

wants to merge 5 commits into from

Conversation

b-izad
Copy link

@b-izad b-izad commented May 13, 2022

No description provided.

Copy link

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

good job, Bahareh! One thing to consider is staying consistent as you can with your route responses. Sometimes you send through just a dictionary, sometimes you jsonify the dictionary, sometimes the status code isn't there, etc.

Double check your routes so that they are formatted consistently and that they have predictable behavior.

Comment on lines +15 to +40
def to_json(self):
if self.completed_at:
is_completed=True
else:
is_completed=False
task_dict= {
"id": self.task_id,
"title": self.title,
"description": self.description,
"is_complete": is_completed,
}
if self.goal_id:
task_dict["goal_id"] = self.goal_id
return task_dict

def to_json_without_des(self):
if self.completed_at:
is_completed=True
else:
is_completed=False
return {
"id": self.task_id,
"title": self.title,
"description": "",
"is_complete": is_completed,
}

Choose a reason for hiding this comment

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

👍 ohhh cool! Interesting way to separate out which tasks need which attributes! I wonder if we could combine these two methods back together with an if statement, though. Something to think about!

Comment on lines +11 to +12
goal_list_bp = Blueprint("goal_list", __name__,url_prefix="/goals")

Choose a reason for hiding this comment

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

one thing we could do to help with too much in one file is by separating these two blueprints out into their own files. This can help bigger teams work on different tasks in a project without stepping on each other's toes.

Comment on lines +15 to +26
try:
task_id = int(task_id)
except:
abort(make_response({"message":f"task {task_id} invalid"}, 400))

task = Task.query.get(task_id)

if not task:
abort(make_response({"message":f"task {task_id} not found"}, 404))

return task

Choose a reason for hiding this comment

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

we could put this in a separate file to keep our routes file tidier

Comment on lines +44 to +46


Choose a reason for hiding this comment

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

be careful with too much blank lines! it can make code harder to read

Suggested change

Comment on lines +27 to +29


Choose a reason for hiding this comment

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

Suggested change

Comment on lines +185 to +186
)

Choose a reason for hiding this comment

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

Suggested change
new_goal = Goal(title=request_body["title"],
)
new_goal = Goal(title=request_body["title"])

Comment on lines +201 to +204
"id": goal.goal_id,
"title": goal.title,
}}

Choose a reason for hiding this comment

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

don't forget your status code!

Comment on lines +256 to +263

for task in tasks:
task_list.append(task.to_json())
return make_response(jsonify({
"id": goal.goal_id,
"title": goal.title,
"tasks": task_list

Choose a reason for hiding this comment

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

just as we made a to_json method for tasks, we could do the same for goals

Comment on lines +271 to +273


Choose a reason for hiding this comment

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

Suggested change


#Post tasks to a goal
@goal_list_bp.route("/<goal_id>/tasks", methods=["POST"])

Choose a reason for hiding this comment

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

👍

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.

3 participants