precache-fix
All checks were successful
deploy / deploy (push) Successful in 1m5s

This commit is contained in:
2023-12-19 18:13:37 +03:00
parent 531eb1f028
commit 95a237f349
8 changed files with 21 additions and 29 deletions

View File

@@ -6,7 +6,7 @@ from models.chat import ChatPayload, Message
from models.member import ChatMember
from resolvers.chats import create_chat
from services.auth import login_required
from services.core import authors_by_id, get_my_followed, authors_by_user
from services.core import authors_by_id, get_my_followed
from services.rediscache import redis
from services.schema import query
@@ -52,9 +52,7 @@ async def load_messages(
@login_required
async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Union[List[Dict[str, Any]], None]]:
"""load :limit chats of current user with :offset"""
user_id = info.context["user_id"]
author = authors_by_user[user_id]
author_id = author["id"]
author_id = info.context["author_id"]
chats = []
if author_id:
cids = await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")
@@ -90,9 +88,7 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Uni
@login_required
async def load_messages_by(_, info, by, limit: int = 10, offset: int = 0):
"""load :limit messages of :chat_id with :offset"""
user_id = info.context["user_id"]
author = authors_by_user[user_id]
author_id = author["id"]
author_id = info.context["author_id"]
author_chats = (await redis.execute("SMEMBERS", "chats_by_author/" + str(author_id))) or []
author_chats = [c for c in author_chats]
if author_chats: