stat-fix-5

This commit is contained in:
2023-12-02 23:38:28 +03:00
parent 2e3e79f51e
commit ebe034a527
4 changed files with 23 additions and 51 deletions

View File

@@ -24,10 +24,8 @@ def add_topic_stat_columns(q):
q = (
q.outerjoin(ShoutTopic, Topic.id == ShoutTopic.topic)
.add_columns(func.count(distinct(ShoutTopic.shout)).label("shouts_stat"))
.outerjoin(aliased_shout_author, ShoutTopic.shout == aliased_shout_author.shout)
.add_columns(func.count(distinct(aliased_shout_author.author)).label("authors_stat"))
.outerjoin(aliased_topic_follower)
.add_columns(func.count(distinct(aliased_topic_follower.follower)).label("followers_stat"))
)