-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feat/review with submission #459
Conversation
# We do not want the review to be deleted when the original requestee is deleted, | ||
# there could be e.g., shared ownership in which case the review data should be preserved. | ||
requestee_identifier: str | None = Field( | ||
foreign_key="user.subject_identifier", | ||
ondelete="SET NULL", | ||
exclude=True, |
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 the field is now only defined on the ORM class and not on the classes returned by FastAPI, we no longer need to protect it from being serialized.
def get_session(): | ||
with DbSession() as session: | ||
yield session |
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.
This is useful to allow a session to be alive also during the FastAPI layer, where the function's return object (e.g., Submission) is coerced into the model response (e.g., SubmissionWithReviews), which may require access to database data (e.g., submission.reviews). The alternative is always eagerly loading the reviews, but that is much worse performance-wise. We probably should rewrite some other endpoints to also use this pattern.
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 good.
Change
When retrieving a submission by ID its reviews will also be returned.
I abstained from also adding it to the listing endpoint which returns multiple submissions.
I figured the main purpose for those calls is to find submissions which need a review, so it felt unnecessary.
We can easily add it later if it turns out to be used in use cases where people want the review too.
How to Test
A new unit test is introduced that covers this.
To test it manually, process an asset through the review pipeline, and then request the submission using the
submissions/v1/{identifier}
endpoint.Checklist
Related Issues
Closes #457