configured isort, black, flake8

This commit is contained in:
Igor Lobanov
2023-10-30 22:00:55 +01:00
parent 17c29c7f4f
commit 441bcc1e90
75 changed files with 2420 additions and 1730 deletions

View File

@@ -1,5 +1,7 @@
import asyncio
import json
from typing import List
from base.redis import redis
from orm.shout import Shout
from resolvers.zine.load import load_shouts_by
@@ -7,25 +9,20 @@ from resolvers.zine.load import load_shouts_by
class SearchService:
lock = asyncio.Lock()
cache = {}
# cache = {}
@staticmethod
async def init(session):
async with SearchService.lock:
print('[search.service] did nothing')
SearchService.cache = {}
print("[search.service] did nothing")
# SearchService.cache = {}
@staticmethod
async def search(text, limit, offset) -> [Shout]:
async def search(text, limit, offset) -> List[Shout]:
cached = await redis.execute("GET", text)
if not cached:
async with SearchService.lock:
options = {
"title": text,
"body": text,
"limit": limit,
"offset": offset
}
options = {"title": text, "body": text, "limit": limit, "offset": offset}
payload = await load_shouts_by(None, None, options)
await redis.execute("SET", text, json.dumps(payload))
return payload