get_cached_author-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m8s

This commit is contained in:
Untone 2024-06-05 18:46:01 +03:00
parent 6e80942beb
commit 1e0d0f465a

View File

@ -77,9 +77,15 @@ async def get_cached_author(author_id: int, get_with_stat):
async def get_cached_author_by_user_id(user_id: str, get_with_stat): async def get_cached_author_by_user_id(user_id: str, get_with_stat):
author_dict = await redis.execute("GET", f"author:user:{user_id}") author_dict = await redis.execute("GET", f"author:user:{user_id}")
author_id = None
if not author_dict:
with local_session() as session:
author_id = session.query(Author.id).filter(Author.user == user_id).first()
else:
author_id = author_dict.get("id") author_id = author_dict.get("id")
if author_id: if author_id:
return await get_cached_author(int(author_id), get_with_stat) cached_author = await get_cached_author(int(author_id), get_with_stat)
return cached_author
async def get_cached_topic_by_slug(slug: str, get_with_stat): async def get_cached_topic_by_slug(slug: str, get_with_stat):