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

Snow Leopards - Aretta B. #136

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

Snow Leopards - Aretta B. #136

wants to merge 18 commits into from

Conversation

arettab
Copy link

@arettab arettab commented Nov 16, 2022

No description provided.

Copy link

@marciaga marciaga left a comment

Choose a reason for hiding this comment

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

Great work! See individual comments for more details. Overall, the structure and presentation of the routes and models is good as well as the added tests.

task_as_dict["goal_id"] = self.goal_id
task_as_dict["title"] = self.title
task_as_dict["description"] = self.description
task_as_dict["is_complete"] = bool(self.completed_at)

Choose a reason for hiding this comment

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

Nice job handling this one!


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

def validate_model(cls, model_id):

Choose a reason for hiding this comment

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

Since validate_model is duplicated in task routes as well as goal routes, we could extract it into a separate route_helpers file and import it as needed!

"id":new_task.task_id,
"title": new_task.title,
"description": new_task.description,
"is_complete": bool(new_task.completed_at)

Choose a reason for hiding this comment

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

Even though a new task is logically not going to be completed in the same request in which it's being created, I like how you're handling it here instead of hard-coding is_complete = False.

SLACK_API_TOKEN = os.environ.get("SLACK_API_TOKEN")

data= {"channel":"task-notifications", "text":f"Someone just completed the task {task.title}"}
headers = {"Authorization": SLACK_API_TOKEN}

Choose a reason for hiding this comment

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

Looking at this value obtained from the environment, I suspect your file would contain something like SLACK_API_TOKEN=Bearer xoxb-... however I'd recommend using an f-string to add the "Bearer " text so that in case the API token needs to be included elsewhere without the "Bearer " prepended to it, it will be reusable.


task.completed_at = datetime.datetime.utcnow()

slack_bot(task)

Choose a reason for hiding this comment

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

We might want to wrap this in a try/except since if the call to Slack fails, we will presumably still want to return a success message to the client.

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