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

Cedar - Jessica - Task List #74

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

Conversation

Jessicawyn
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!

I left a few little comments on tweaks you could make but overall everything looked really good! Well done!

token = os.environ.get('SLACK_TOKEN')
CHANNEL_ID = "C02KD4B5A07"

Headers = {"Authorization": "Bearer xoxb-" + token}

Choose a reason for hiding this comment

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

This line causes a failure if the SLACK_TOKEN doesn't exist in the environment (which is why the automated tests fail).

It's perfectly reasonable to assume you will have a key (and the tests pass if given the token of token so would work if the token was expired) this was just a quirk of our Learn setup.

If you wanted to fix the test failures you could use interpolation to do this instead:

Suggested change
Headers = {"Authorization": "Bearer xoxb-" + token}
Headers = {"Authorization": f"Bearer xoxb-{token}"}

Again, this isn't a bug, just a quirk of our Learn setup.

It's just the kind of thing where I would want to know why it failed on Learn and not on my local machine.

@@ -1,6 +1,30 @@
from re import T

Choose a reason for hiding this comment

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

You're the second person I've seen import this but I'm not sure what effect it actually has (it doesn't seem explicitly referenced).

I'm curious, why the import?

Comment on lines +16 to +18
def get_goal_from_id(goal_id):
valid_int(goal_id, "goal_id")
return Goal.query.get_or_404(goal_id, description="{goal not found}")

Choose a reason for hiding this comment

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

Since get_or_404 returns HTML and not JSON by default you might want like this instead:

Suggested change
def get_goal_from_id(goal_id):
valid_int(goal_id, "goal_id")
return Goal.query.get_or_404(goal_id, description="{goal not found}")
def get_goal_from_id(goal_id):
valid_int(goal_id, "goal_id")
goal = Goal.query.get(goal_id)
if goal:
return goal
else:
abort(make_response({"description": "goal not found"}, 404))

db.session.delete(goal)
db.session.commit()

return make_response({"details": f"Goal {goal.goal_id} \"{goal.title}\" successfully deleted"}, 200)

Choose a reason for hiding this comment

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

This is a really good message! Very clear. 😄

task.goal_id = goal_id
db.session.commit()
response_body = {
"id": int(goal_id),

Choose a reason for hiding this comment

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

Remember, if goal_id is invalid this will cause an exception.

It may be worth using your valid_int helper here.

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