shout-topic-comments
Some checks failed
Deploy on push / deploy (push) Failing after 7s

This commit is contained in:
Untone 2024-04-09 19:48:02 +03:00
parent 142a5f09af
commit d3262accc5

View File

@ -41,8 +41,8 @@ def add_topic_stat_columns(q):
Shout.id.label('shout_id'),
func.coalesce(func.count(Reaction.id)).label('comments_count')
)
.join(ShoutTopic, Topic.id == ShoutTopic.topic)
.join(Shout, ShoutTopic.shout == Shout.id)
.join(ShoutTopic, ShoutTopic.shout == Shout.id)
.join(Topic, ShoutTopic.topic == Topic.id)
.outerjoin(
Reaction,
and_(
@ -55,6 +55,7 @@ def add_topic_stat_columns(q):
.subquery()
)
q = q.outerjoin(sub_comments, aliased_shout_topic.shout == sub_comments.c.shout_id)
q = q.add_columns(func.coalesce(sub_comments.c.comments_count, 0).label('comments_stat'))