Add sequences to books by author and translator

This commit is contained in:
2023-05-26 22:41:56 +02:00
parent 7462ca5b72
commit 5628fe1d27
2 changed files with 6 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ from typing import Optional
from pydantic import BaseModel
from app.serializers.sequence import Sequence
class Author(BaseModel):
id: int
@@ -22,6 +24,7 @@ class AuthorBook(BaseModel):
available_types: list[str]
uploaded: date
translators: list[Author]
sequences: list[Sequence]
annotation_exists: bool
@@ -32,4 +35,5 @@ class TranslatedBook(BaseModel):
file_type: str
available_types: list[str]
authors: list[Author]
sequences: list[Sequence]
annotation_exists: bool

View File

@@ -87,7 +87,7 @@ async def get_author_books(
):
return await paginate(
BookDB.objects.prefetch_related(["source"])
.select_related(["annotations", "translators"])
.select_related(["annotations", "translators", "sequences"])
.filter(authors__id=id, lang__in=allowed_langs, is_deleted=False)
.order_by("title")
)
@@ -120,7 +120,7 @@ async def get_translated_books(
):
return await paginate(
BookDB.objects.prefetch_related(["source"])
.select_related(["annotations", "authors"])
.select_related(["annotations", "authors", "sequences"])
.filter(
translators__id=id,
lang__in=allowed_langs,