follower-groupby2
Some checks failed
Deploy on push / deploy (push) Failing after 9s

This commit is contained in:
Untone 2024-08-07 18:06:31 +03:00
parent fb687d50dd
commit 8b377123e1

View File

@ -82,7 +82,9 @@ def query_shouts():
Shout, Shout,
ShoutReactionsFollower, ShoutReactionsFollower,
func.count(case((aliased_reaction.body.is_not(None), 1))).label("comments_stat"), func.count(case((aliased_reaction.body.is_not(None), 1))).label("comments_stat"),
func.count(ShoutReactionsFollower.follower).filter(ShoutReactionsFollower.shout == Shout.id).label("followers_stat"), func.count(ShoutReactionsFollower.follower)
.filter(ShoutReactionsFollower.shout == Shout.id)
.label("followers_stat"),
func.sum( func.sum(
case( case(
(aliased_reaction.kind == ReactionKind.LIKE.value, 1), (aliased_reaction.kind == ReactionKind.LIKE.value, 1),
@ -98,7 +100,13 @@ def query_shouts():
.outerjoin(authors_subquery, authors_subquery.c.shout_id == Shout.id) .outerjoin(authors_subquery, authors_subquery.c.shout_id == Shout.id)
.outerjoin(topics_subquery, topics_subquery.c.shout_id == Shout.id) .outerjoin(topics_subquery, topics_subquery.c.shout_id == Shout.id)
.where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None))) .where(and_(Shout.published_at.is_not(None), Shout.deleted_at.is_(None)))
.group_by(Shout.id, authors_subquery.c.authors, topics_subquery.c.topics, ShoutReactionsFollower.follower) .group_by(
Shout.id,
authors_subquery.c.authors,
topics_subquery.c.topics,
ShoutReactionsFollower.follower,
ShoutReactionsFollower.shout,
)
) )
return q, aliased_reaction return q, aliased_reaction