Use sets for random

This commit is contained in:
2022-04-02 17:30:12 +03:00
parent 2f6a4a192a
commit b13976d017
4 changed files with 39 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends, Request, HTTPException, status
from fastapi import APIRouter, BackgroundTasks, Depends, Request, HTTPException, status
from fastapi_pagination import Params
from fastapi_pagination.ext.ormar import paginate
@@ -55,10 +55,12 @@ async def create_author(data: CreateAuthor):
@author_router.get("/random", response_model=Author)
async def get_random_author(
request: Request, allowed_langs: frozenset[str] = Depends(get_allowed_langs)
request: Request,
background_tasks: BackgroundTasks,
allowed_langs: frozenset[str] = Depends(get_allowed_langs),
):
author_id = await GetRandomAuthorService.get_random_id(
allowed_langs, request.app.state.redis
allowed_langs, request.app.state.redis, background_tasks
)
return (