Fix joins and subqueries

This commit is contained in:
2022-01-22 21:49:08 +03:00
parent 1bdc2733a2
commit c43636731b
9 changed files with 69 additions and 29 deletions

View File

@@ -47,9 +47,8 @@ async def get_sequence_books(
id: int, allowed_langs: list[str] = Depends(get_allowed_langs)
):
return await paginate(
BookDB.objects.select_related(
["source", "annotations", "authors", "translators"]
)
BookDB.objects.select_related(["source"])
.prefetch_related(["annotations", "authors", "translators"])
.filter(sequences__id=id, lang__in=allowed_langs, is_deleted=False)
.order_by("sequences__booksequences__position")
)