This commit is contained in:
parent
e9c852d23d
commit
8ff0e6786b
|
@ -83,7 +83,6 @@ def add_author_stat_columns(q, with_rating=False):
|
|||
func.count(distinct(aliased_followers.follower)).label('followers_stat')
|
||||
)
|
||||
|
||||
if not with_rating:
|
||||
# Create a subquery for comments count
|
||||
select_list = [
|
||||
Author.id,
|
||||
|
@ -106,7 +105,6 @@ def add_author_stat_columns(q, with_rating=False):
|
|||
|
||||
q = q.outerjoin(sub_comments, Author.id == sub_comments.c.id)
|
||||
q = q.add_columns(sub_comments.c.comments_count)
|
||||
q = q.group_by(Author.id, sub_comments.c.comments_count)
|
||||
|
||||
if with_rating:
|
||||
# Create a subquery for ratings counters
|
||||
|
@ -146,6 +144,11 @@ def add_author_stat_columns(q, with_rating=False):
|
|||
sub_rating.c.shouts_likes,
|
||||
sub_rating.c.shouts_dislikes,
|
||||
)
|
||||
else:
|
||||
q = q.group_by(
|
||||
Author.id,
|
||||
sub_comments.c.comments_count
|
||||
)
|
||||
|
||||
return q
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user