core/services/search.py

25 lines
593 B
Python
Raw Normal View History

2022-10-04 00:32:29 +00:00
import asyncio
2022-10-04 00:32:29 +00:00
from orm.shout import Shout
from resolvers.zine import load_shouts_by
2022-10-04 00:32:29 +00:00
class SearchService:
lock = asyncio.Lock()
cache = {}
@staticmethod
2022-10-04 09:25:59 +00:00
async def init(session):
async with SearchService.lock:
2022-11-15 12:04:22 +00:00
print('[search.service] init')
2022-10-04 09:25:59 +00:00
SearchService.cache = {}
2022-10-04 00:32:29 +00:00
@staticmethod
async def search(text, limit, offset) -> [Shout]:
2022-10-04 09:25:59 +00:00
async with SearchService.lock:
by = {
"title": text,
"body": text
}
return await load_shouts_by(None, None, by, limit, offset)