mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Add get_last_book endpoint
This commit is contained in:
@@ -38,6 +38,20 @@ async def get_books(
|
||||
return await BookFilterService.get(book_filter, request.app.state.redis)
|
||||
|
||||
|
||||
@book_router.get("/last", response_model=CustomPage[RemoteBook])
|
||||
async def get_last_book():
|
||||
book = (
|
||||
await BookDB.objects.select_related(
|
||||
SELECT_RELATED_FIELDS + DETAIL_SELECT_RELATED_FIELDS
|
||||
)
|
||||
.prefetch_related(PREFETCH_RELATED_FIELDS)
|
||||
.order_by("-id")
|
||||
.first()
|
||||
)
|
||||
|
||||
return book
|
||||
|
||||
|
||||
@book_router.get("/random", response_model=BookDetail)
|
||||
async def get_random_book(
|
||||
request: Request,
|
||||
|
||||
Reference in New Issue
Block a user