-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from http import HTTPStatus | ||
from fastapi import Depends, HTTPException | ||
from sqlalchemy import select | ||
from sqlalchemy.orm import selectinload | ||
from src.common.dependencies import get_session | ||
from src.events.models import Analysis, Event, GPQuestion | ||
|
||
|
||
def retrieve_event( | ||
id: int, | ||
session=Depends(get_session), | ||
): | ||
event = session.scalar( | ||
select(Event) | ||
.where(Event.id == id) | ||
.options( | ||
selectinload( | ||
Event.gp_questions, | ||
GPQuestion.categories, | ||
), | ||
selectinload( | ||
Event.categories, | ||
), | ||
selectinload(Event.analysises, Analysis.category), | ||
) | ||
) | ||
if not event: | ||
raise HTTPException(HTTPStatus.NOT_FOUND) | ||
|
||
return event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters