From 67c299939c375dfd0dee91a4d2281ea71c765fa9 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 5 Jun 2024 16:23:53 +0300 Subject: [PATCH] toler-no-author --- services/cache.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/cache.py b/services/cache.py index d819f9eb..1ad3d04c 100644 --- a/services/cache.py +++ b/services/cache.py @@ -66,10 +66,12 @@ async def get_cached_author(author_id: int, get_with_stat): elif get_with_stat: with local_session() as session: author_query = select(Author).filter(Author.id == author_id) - [author] = get_with_stat(session.execute(author_query)) - if author: - await cache_author(author) - return author + result = get_with_stat(session.execute(author_query)) + if result: + [author] = result + if author: + await cache_author(author) + return author async def get_cached_author_by_user_id(user_id: str, get_with_stat):