Skip to content

Conversation

@gabw13
Copy link

@gabw13 gabw13 commented May 13, 2022

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 noted a couple of small stylistic things but overall everything looks really solid.

Well done!

Comment on lines +10 to +14
goal_dict = {
"id": self.goal_id,
"title": self.title,
}
return goal_dict

Choose a reason for hiding this comment

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

Since you immediately return this you don't need to assign it to a variable:

Suggested change
goal_dict = {
"id": self.goal_id,
"title": self.title,
}
return goal_dict
return {
"id": self.goal_id,
"title": self.title,
}

Comment on lines +11 to +19
task_dict = {
"id": self.task_id,
"title": self.title,
"description": self.description
}
if self.completed_at is None:
task_dict["is_complete"] = False
else:
task_dict["is_complete"] = True

Choose a reason for hiding this comment

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

This can be simplified to:

Suggested change
task_dict = {
"id": self.task_id,
"title": self.title,
"description": self.description
}
if self.completed_at is None:
task_dict["is_complete"] = False
else:
task_dict["is_complete"] = True
task_dict = {
"id": self.task_id,
"title": self.title,
"description": self.description,
"is_complete": bool(self.completed_at)
}

title = db.Column(db.String)
tasks = db.relationship('Task', backref='goal', lazy=True)

def create_goal_dict(self):

Choose a reason for hiding this comment

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

Style: Since this is a method on the Goal class having goal in the name is redundant:

Suggested change
def create_goal_dict(self):
def create_dict(self):

}
return response

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.

I like this helper function. It's really clearly named and clean. 😃

(You even have great error messages!)

"authorization": "Bearer " + os.environ.get("SLACKBOT_API_KEY")
}

post_message = requests.post(path, data=data, headers=headers)

Choose a reason for hiding this comment

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

Style: Since you don't do anything with this variable it's a best practice not to store it:

Suggested change
post_message = requests.post(path, data=data, headers=headers)
requests.post(path, data=data, headers=headers)

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