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

[ITG-44] Implementacja endpointu GET do pobrania zadań będących w relacji z danym zadaniem #22

Merged
merged 12 commits into from
Apr 27, 2022

Conversation

koszar91
Copy link
Contributor

No description provided.

bode/bode/resources/tasks/schemas.py Outdated Show resolved Hide resolved
Comment on lines 36 to 45
@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.")
Copy link
Collaborator

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.

Copy link
Contributor

@gregori0o gregori0o left a 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.

bode/bode/resources/tasks/schemas.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@john-sonz john-sonz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@gregori0o gregori0o left a comment

Choose a reason for hiding this comment

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

Good job!

@koszar91 koszar91 merged commit 437d0ee into develop Apr 27, 2022
@koszar91 koszar91 deleted the feature/ITG-44 branch April 27, 2022 15:05
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.

None yet

3 participants