diff --git a/resolvers/reader.py b/resolvers/reader.py index 3cedac16..98f202a0 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -441,16 +441,10 @@ async def load_shouts_unrated(_, info, options): .scalar_subquery() ) - # add topic inside output data in main_topic field - aliased_topic = aliased(Topic) - - q = ( - select(Shout) - .join(aliased_topic, aliased_topic.id == Shout.main_topic.id) - .where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None), ~Shout.id.in_(rated_shouts))) - # .order_by(desc(Shout.published_at)) - .order_by(func.random()) - ) + q = query_with_stat(info) + q = q.where(~Shout.id.in_(rated_shouts)) + q = q.order_by(func.random()) + limit = options.get("limit", 5) offset = options.get("offset", 0) return get_shouts_with_links(info, q, limit, offset)