mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2026-03-03 23:20:52 +01:00
Fix random handlers
This commit is contained in:
@@ -43,6 +43,9 @@ async def get_random_author(
|
||||
{"allowed_langs": allowed_langs}, request.app.state.redis
|
||||
)
|
||||
|
||||
if author_id is None:
|
||||
raise HTTPException(status.HTTP_204_NO_CONTENT)
|
||||
|
||||
return (
|
||||
await AuthorDB.objects.select_related(SELECT_RELATED_FIELDS)
|
||||
.prefetch_related(PREFETCH_RELATED_FIELDS)
|
||||
|
||||
@@ -64,6 +64,9 @@ async def get_random_book(
|
||||
{"allowed_langs": allowed_langs, "genre": genre}, request.app.state.redis
|
||||
)
|
||||
|
||||
if book_id is None:
|
||||
raise HTTPException(status.HTTP_204_NO_CONTENT)
|
||||
|
||||
book = (
|
||||
await BookDB.objects.select_related(
|
||||
SELECT_RELATED_FIELDS + DETAIL_SELECT_RELATED_FIELDS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
|
||||
from fastapi_pagination import Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
@@ -34,6 +34,9 @@ async def get_random_sequence(
|
||||
request.app.state.redis,
|
||||
)
|
||||
|
||||
if sequence_id is None:
|
||||
raise HTTPException(status.HTTP_204_NO_CONTENT)
|
||||
|
||||
return await SequenceDB.objects.get(id=sequence_id)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user