Skip to content

Lions - Jessica Ambriz-Madrigal #127

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

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

Conversation

Jessicaenvisions
Copy link

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.

Nice work Jessica, you hit the learning goals here. I left some minor comments in the code. If you have questions on them please let me know via Slack.

Comment on lines +42 to +46





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 +14 to +37
if self.completed_at is None:
if self.goal_id is None:
task_dict = {
"id":self.id,
"title":self.title,
"description":self.description,
"is_complete": False
}
else:
task_dict = {
"id":self.id,
"goal_id": self.goal_id,
"title":self.title,
"description":self.description,
"is_complete": False
}
else:
task_dict = {
"id":self.id,
"title":self.title,
"description":self.description,
"is_complete": True
}
return task_dict

Choose a reason for hiding this comment

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

This seems a little over-complicated. Could you do the basic dictionary in one block and then add key-value pairs based on an if-else?

task_bp = Blueprint("task_bp",__name__, url_prefix="/tasks")

def get_one_task_or_abort(task_id):

Choose a reason for hiding this comment

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

Good helper function

Comment on lines +30 to +32
"description" not in request_body:
return jsonify({"details": "Invalid data"}), 400

Choose a reason for hiding this comment

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

Good validation here. However I think you should also indicate what data is invalid.

Comment on lines +42 to +49
"task":{
"id" : new_task.id,
"title" : new_task.title,
"description" : new_task.description,
"is_complete" : new_task.is_complete
}
}, 201

Choose a reason for hiding this comment

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

This return value might be useful as a helper function for reuse.

Comment on lines +57 to +64
tasks = Task.query.all()

if sort_param == "desc":
tasks = Task.query.order_by(Task.title.desc()).all()

if sort_param == "asc":
tasks = Task.query.order_by(Task.title.asc()).all()

Choose a reason for hiding this comment

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

This might cause Task.query to execute twice making this potentially twice as slow as it needs to be.

Comment on lines +117 to +128
SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN")

headers = {
"Authorization" : f"Bearer {SLACK_BOT_TOKEN}"
}
params = {
"channel": "task-notifications",
"text": f"Someone just completed the task {update_is_valid_id.title}"
}

requests.get(url=SLACK_PATH, headers=headers, params=params)

Choose a reason for hiding this comment

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

The Slack portion would make a good candidate for a helper function.

Comment on lines +165 to +166
return jsonify({"details": "Invalid data"}), 400

Choose a reason for hiding this comment

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

Again indicating what data is invalid would be useful.

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