-
Notifications
You must be signed in to change notification settings - Fork 146
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
No description provided.