random-topic-shouts-patch-2
All checks were successful
Deploy on push / deploy (push) Successful in 25s

This commit is contained in:
Untone 2024-02-28 18:20:58 +03:00
parent 7a3ce4a982
commit 6c0b43bd14

View File

@ -461,11 +461,11 @@ async def load_shouts_random_top(_, _info, options):
@query.field('load_shouts_random_topic') @query.field('load_shouts_random_topic')
async def load_shouts_random_topic(_, info, limit: int = 10): async def load_shouts_random_topic(_, info, limit: int = 10):
random_topic_subquery = random_topic_query(1) random_topic_subquery = random_topic_query(1).subquery()
q = ( q = (
select(Shout, Topic) select(Topic, Shout)
.join(Shout.topics) .select_from(Topic)
.join(random_topic_subquery, Topic.id == random_topic_subquery.c.id) .join(Shout, Shout.topics.any(Topic.id == random_topic_subquery.c.id))
.options(joinedload(Shout.authors)) .options(joinedload(Shout.authors))
.filter( .filter(
and_( and_(