morning-fixes

This commit is contained in:
2022-11-26 03:55:45 +03:00
parent 839485873a
commit 228cdf21e9
5 changed files with 74 additions and 80 deletions

View File

@@ -20,11 +20,13 @@ class SearchService:
cached = await redis.execute("GET", text)
if not cached:
async with SearchService.lock:
by = {
options = {
"title": text,
"body": text
"body": text,
"limit": limit,
"offset": offset
}
payload = await load_shouts_by(None, None, by, limit, offset)
payload = await load_shouts_by(None, None, options)
await redis.execute("SET", text, json.dumps(payload))
return payload
else:

View File

@@ -3,7 +3,6 @@ import time
from base.orm import local_session
from orm.reaction import ReactionKind, Reaction
from services.zine.topics import TopicStorage
from services.stat.viewed import ViewedStorage
def kind_to_rate(kind) -> int:
@@ -34,18 +33,6 @@ class ReactedStorage:
lock = asyncio.Lock()
modified_shouts = set([])
@staticmethod
async def get_shout_stat(slug, rating):
viewed = int(await ViewedStorage.get_shout(slug))
# print(viewed)
return {
"viewed": viewed,
"reacted": len(await ReactedStorage.get_shout(slug)),
"commented": len(await ReactedStorage.get_comments(slug)),
# "rating": await ReactedStorage.get_rating(slug),
"rating": rating
}
@staticmethod
async def get_shout(shout_slug):
self = ReactedStorage
@@ -59,7 +46,7 @@ class ReactedStorage:
return self.reacted["authors"].get(user_slug, [])
@staticmethod
async def get_shouts_by_author(user_slug):
async def get_followed_reactions(user_slug):
self = ReactedStorage
async with self.lock:
author_reactions = self.reacted["authors"].get(user_slug, [])