diff --git a/resolvers/reader.py b/resolvers/reader.py index bb25c9db..8a862919 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -328,7 +328,7 @@ async def load_shouts_unrated(_, info, limit: int = 50, offset: int = 0): q.outerjoin( Reaction, and_( - Reaction.shout_id == Shout.id, + Reaction.shout == Shout.id, Reaction.reply_to.is_(None), Reaction.kind.in_([ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]), ), diff --git a/services/cache.py b/services/cache.py index 5a7bb54b..c57a603b 100644 --- a/services/cache.py +++ b/services/cache.py @@ -101,13 +101,11 @@ async def get_cached_topic_by_slug(slug: str, get_with_stat): with local_session() as session: topic_query = select(Topic).filter(Topic.slug == slug) result = get_with_stat(session.execute(topic_query)) - if isinstance(result, list) and len(result) > 0: - [topic] = result - elif isinstance(result, Topic): - topic = result - if topic: - await cache_topic(topic) - return topic + if result: + topic = result if isinstance(result, Topic) else result[0] + if topic: + await cache_topic(topic) + return topic async def get_cached_authors_by_ids(authors_ids: List[int]) -> List[Author | dict]: