search-query-fix-5
All checks were successful
deploy / deploy (push) Successful in 1m28s

This commit is contained in:
Untone 2023-12-25 04:56:30 +03:00
parent c76e1625f3
commit ec70549e48
2 changed files with 2 additions and 1 deletions

View File

@ -287,7 +287,7 @@ async def load_shouts_feed(_, info, options):
async def load_shouts_search(_, _info, text, limit=50, offset=0):
if text and len(text) > 2:
results = await SearchService.search(text, limit, offset)
results_dict = {[s.slug]: s for s in results} # { slug, title, score }
results_dict = {[s["slug"]]: s for s in results} # { slug, title, score }
q = (
select(Shout) # Add "score" column
.options(

View File

@ -21,6 +21,7 @@ class SearchService:
async def search(text: str, limit: int = 50, offset: int = 0) -> List[Shout]:
payload = []
try:
# TODO: add ttl for redis cached search results
cached = await redis.execute("GET", text)
if not cached: