-
Notifications
You must be signed in to change notification settings - Fork 1
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
[ITG-44] Implementacja endpointu GET do pobrania zadań będących w relacji z danym zadaniem #22
Conversation
@blueprint.route("/<task_id>") | ||
class TasksInRelationWith(MethodView): | ||
@blueprint.response(200, TasksRelationSchema(many=True)) | ||
def get(self, task_id): | ||
try: | ||
return TaskRelation.query.filter(TaskRelation.first_task_id == task_id).all() or abort(404) | ||
except DataError: | ||
abort(404) | ||
except NoResultFound: | ||
abort(404, message="Item not found.") |
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.
Getting only the relations record is not really useful. When using this API route you'd want to have some data about the related tasks in the response, like title
, due_date
, etc. The response scheme should more or less look like this:
class RelatedTaskSchema(BaseSchema):
id = fields.UUID(dump_only=True) # relation id
type = fields.String() # relation type
related_task = fields.nested(TaskSchema) # the task object that is related that is in relation with the given task
Also, you don't need to catch these errors when returning lists. A response with an empty list of related tasks is not exceptional and should return 200 response code.
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.
Looks great. I found duplicates in code, so you should choose one version.
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.
LGTM
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.
Good job!
…d tasks). Made task deletion operation recursive (according to subtasks).
No description provided.