Use redis list for base search service

This commit is contained in:
2022-04-02 18:31:27 +03:00
parent b13976d017
commit 8138444b9f
5 changed files with 68 additions and 46 deletions

View File

@@ -1,4 +1,4 @@
from fastapi import APIRouter, BackgroundTasks, Depends, Request
from fastapi import APIRouter, Depends, Request
from fastapi_pagination import Params
from fastapi_pagination.ext.ormar import paginate
@@ -29,13 +29,11 @@ async def get_sequences():
@sequence_router.get("/random", response_model=Sequence)
async def get_random_sequence(
request: Request,
background_tasks: BackgroundTasks,
allowed_langs: frozenset[str] = Depends(get_allowed_langs),
):
sequence_id = await GetRandomSequenceService.get_random_id(
allowed_langs,
request.app.state.redis,
background_tasks,
)
return await SequenceDB.objects.get(id=sequence_id)
@@ -78,5 +76,6 @@ async def search_sequences(
allowed_langs: frozenset[str] = Depends(get_allowed_langs),
):
return await SequenceMeiliSearchService.get(
{"query": query, "allowed_langs": allowed_langs}, request.app.state.redis
{"query": query, "allowed_langs": allowed_langs},
request.app.state.redis,
)