postmerge
All checks were successful
deploy / deploy (push) Successful in 1m26s

This commit is contained in:
2023-12-22 21:08:37 +03:00
parent 4e769332b7
commit d3ea567797
4 changed files with 41 additions and 1 deletions

View File

@@ -187,3 +187,15 @@ async def get_topics_random(_, info, amount=12):
topics.append(topic)
return topics
def get_random_topic():
q = select(Topic)
q = q.join(ShoutTopic)
q = q.group_by(Topic.id)
q = q.having(func.count(distinct(ShoutTopic.shout)) > 10)
q = q.order_by(func.random()).limit(1)
topic = None
with local_session() as session:
topic = session.execute(q).first()
return topic