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')
|
func.count(distinct(aliased_followers.follower)).label('followers_stat')
|
||||||
)
|
)
|
||||||
|
|
||||||
if not with_rating:
|
|
||||||
# Create a subquery for comments count
|
# Create a subquery for comments count
|
||||||
select_list = [
|
select_list = [
|
||||||
Author.id,
|
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.outerjoin(sub_comments, Author.id == sub_comments.c.id)
|
||||||
q = q.add_columns(sub_comments.c.comments_count)
|
q = q.add_columns(sub_comments.c.comments_count)
|
||||||
q = q.group_by(Author.id, sub_comments.c.comments_count)
|
|
||||||
|
|
||||||
if with_rating:
|
if with_rating:
|
||||||
# Create a subquery for ratings counters
|
# 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_likes,
|
||||||
sub_rating.c.shouts_dislikes,
|
sub_rating.c.shouts_dislikes,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
q = q.group_by(
|
||||||
|
Author.id,
|
||||||
|
sub_comments.c.comments_count
|
||||||
|
)
|
||||||
|
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user