From c329b7dd3aa7885a0dabde9f41c554868cdc9362 Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Thu, 1 Dec 2022 19:51:32 +0100 Subject: [PATCH] topics_random fix --- resolvers/zine/topics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resolvers/zine/topics.py b/resolvers/zine/topics.py index 6a904ebf..ad4f8c77 100644 --- a/resolvers/zine/topics.py +++ b/resolvers/zine/topics.py @@ -151,7 +151,7 @@ def topic_unfollow(user_id, slug): async def topics_random(_, info, amount=12): q = select(Topic) q = add_topic_stat_columns(q) - q = q.join(Shout, ShoutTopic.shout == Shout.id).group_by(Topic.id).having(func.count(Shout.id) > 2) + q = q.join(ShoutTopic).join(Shout, ShoutTopic.shout == Shout.id).group_by(Topic.id).having(func.count(Shout.id) > 2) q = q.order_by(func.random()).limit(amount) return get_topics_from_query(q)