This commit is contained in:
parent
248620622a
commit
fbee450bde
|
@ -55,8 +55,7 @@ def add_author_stat_columns(q):
|
||||||
aliased_shout_author = aliased(ShoutAuthor)
|
aliased_shout_author = aliased(ShoutAuthor)
|
||||||
aliased_author_authors = aliased(AuthorFollower)
|
aliased_author_authors = aliased(AuthorFollower)
|
||||||
aliased_author_followers = aliased(AuthorFollower)
|
aliased_author_followers = aliased(AuthorFollower)
|
||||||
|
aliased_reaction = aliased(Reaction)
|
||||||
# aliased_reaction = aliased(Reaction)
|
|
||||||
|
|
||||||
q = (
|
q = (
|
||||||
q.outerjoin(aliased_shout_author, aliased_shout_author.author == Author.id)
|
q.outerjoin(aliased_shout_author, aliased_shout_author.author == Author.id)
|
||||||
|
@ -77,18 +76,19 @@ def add_author_stat_columns(q):
|
||||||
'followers_stat'
|
'followers_stat'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# .add_columns(literal('0')).label('comments_count')
|
.outerjoin(
|
||||||
|
aliased_reaction,
|
||||||
|
and_(
|
||||||
|
aliased_reaction.created_by == Author.id,
|
||||||
|
aliased_reaction.kind == ReactionKind.COMMENT.value,
|
||||||
|
aliased_reaction.deleted_at.is_(None),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.add_columns(
|
||||||
|
func.count(distinct(aliased_reaction.id)).label('comments_stat')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME: author.stat.comments
|
|
||||||
#.outerjoin(aliased_reaction)
|
|
||||||
#func.count(distinct(aliased_reaction.id)).filter(
|
|
||||||
# and_(
|
|
||||||
# aliased_reaction.created_by == Author.id,
|
|
||||||
# aliased_reaction.kind == ReactionKind.COMMENT.value,
|
|
||||||
# aliased_reaction.deleted_at.is_(None),
|
|
||||||
# )
|
|
||||||
|
|
||||||
q = q.group_by(Author.id)
|
q = q.group_by(Author.id)
|
||||||
|
|
||||||
return q
|
return q
|
||||||
|
|
Loading…
Reference in New Issue
Block a user