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