This commit is contained in:
parent
152730526f
commit
90a6e23e61
|
@ -1,4 +1,4 @@
|
|||
from sqlalchemy import func, distinct, select, join, and_, case, true, cast, Integer
|
||||
from sqlalchemy import func, distinct, select, join, and_, case, true, cast, Integer, literal
|
||||
from sqlalchemy.orm import aliased
|
||||
|
||||
from orm.reaction import Reaction, ReactionKind
|
||||
|
@ -56,7 +56,7 @@ def add_author_stat_columns(q):
|
|||
aliased_author_authors = aliased(AuthorFollower)
|
||||
aliased_author_followers = aliased(AuthorFollower)
|
||||
|
||||
aliased_reaction = aliased(Reaction)
|
||||
# aliased_reaction = aliased(Reaction)
|
||||
|
||||
q = (
|
||||
q.outerjoin(aliased_shout_author, aliased_shout_author.author == Author.id)
|
||||
|
@ -77,19 +77,18 @@ def add_author_stat_columns(q):
|
|||
'followers_stat'
|
||||
)
|
||||
)
|
||||
|
||||
.outerjoin(aliased_reaction)
|
||||
# FIXME: author.stat.comments
|
||||
#.outerjoin(aliased_reaction)
|
||||
.add_columns(
|
||||
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),
|
||||
)
|
||||
)
|
||||
.label('comments_count')
|
||||
literal('0')
|
||||
#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),
|
||||
# )
|
||||
).label('comments_count')
|
||||
)
|
||||
)
|
||||
|
||||
q = q.group_by(Author.id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user