This commit is contained in:
parent
142a5f09af
commit
d3262accc5
|
@ -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'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user