Fix async lazy-loading in queue repository

- Add selectinload for episode relationship in get_all()
- Prevents MissingGreenlet error during queue initialization
- Both series and episode are now eagerly loaded
This commit is contained in:
2026-01-23 18:34:00 +01:00
parent 800790fc8f
commit e09bb0451c
2 changed files with 803 additions and 4 deletions

View File

@@ -610,7 +610,7 @@ class DownloadQueueService:
Args:
db: Database session
with_series: Whether to eagerly load series data
with_series: Whether to eagerly load series and episode data
Returns:
List of all DownloadQueueItem instances
@@ -618,7 +618,11 @@ class DownloadQueueService:
query = select(DownloadQueueItem)
if with_series:
query = query.options(selectinload(DownloadQueueItem.series))
# Eagerly load both series and episode relationships
query = query.options(
selectinload(DownloadQueueItem.series),
selectinload(DownloadQueueItem.episode)
)
query = query.order_by(
DownloadQueueItem.created_at.asc(),