mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Fix
This commit is contained in:
@@ -114,9 +114,11 @@ async def get_author_books(
|
|||||||
async def get_author_books_available_types(
|
async def get_author_books_available_types(
|
||||||
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
books = await BookDB.objects.filter(
|
books = await (
|
||||||
authors__id=id, lang__in=allowed_langs, is_deleted=False
|
BookDB.objects.prefetch_related(["source"])
|
||||||
).all()
|
.filter(authors__id=id, lang__in=allowed_langs, is_deleted=False)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
file_types: set[str] = set()
|
file_types: set[str] = set()
|
||||||
|
|
||||||
@@ -124,7 +126,7 @@ async def get_author_books_available_types(
|
|||||||
for file_type in cast(list[str], book.available_types):
|
for file_type in cast(list[str], book.available_types):
|
||||||
file_types.add(file_type)
|
file_types.add(file_type)
|
||||||
|
|
||||||
return list(file_types)
|
return sorted(file_types)
|
||||||
|
|
||||||
|
|
||||||
@author_router.get(
|
@author_router.get(
|
||||||
@@ -179,11 +181,15 @@ async def get_translated_books(
|
|||||||
async def get_translator_books_available_types(
|
async def get_translator_books_available_types(
|
||||||
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
books = await BookDB.objects.filter(
|
books = await (
|
||||||
|
BookDB.objects.prefetch_related(["source"])
|
||||||
|
.filter(
|
||||||
translators__id=id,
|
translators__id=id,
|
||||||
lang__in=allowed_langs,
|
lang__in=allowed_langs,
|
||||||
is_deleted=False,
|
is_deleted=False,
|
||||||
).all()
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
file_types: set[str] = set()
|
file_types: set[str] = set()
|
||||||
|
|
||||||
@@ -191,7 +197,7 @@ async def get_translator_books_available_types(
|
|||||||
for file_type in cast(list[str], book.available_types):
|
for file_type in cast(list[str], book.available_types):
|
||||||
file_types.add(file_type)
|
file_types.add(file_type)
|
||||||
|
|
||||||
return list(file_types)
|
return sorted(file_types)
|
||||||
|
|
||||||
|
|
||||||
@translator_router.get(
|
@translator_router.get(
|
||||||
|
|||||||
@@ -82,9 +82,11 @@ async def get_sequence_books(
|
|||||||
async def sequence_available_types(
|
async def sequence_available_types(
|
||||||
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
id: int, allowed_langs: Annotated[list[str], Depends(get_allowed_langs)]
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
books = await BookDB.objects.filter(
|
books = await (
|
||||||
sequence__id=id, lang__in=allowed_langs, is_deleted=False
|
BookDB.objects.prefetch_related(["source"])
|
||||||
).all()
|
.filter(sequence__id=id, lang__in=allowed_langs, is_deleted=False)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
file_types: set[str] = set()
|
file_types: set[str] = set()
|
||||||
|
|
||||||
@@ -92,7 +94,7 @@ async def sequence_available_types(
|
|||||||
for file_type in cast(list[str], book.available_types):
|
for file_type in cast(list[str], book.available_types):
|
||||||
file_types.add(file_type)
|
file_types.add(file_type)
|
||||||
|
|
||||||
return list(file_types)
|
return sorted(file_types)
|
||||||
|
|
||||||
|
|
||||||
@sequence_router.get(
|
@sequence_router.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user