add_author_stat-fix-2

This commit is contained in:
Untone 2024-03-06 12:34:17 +03:00
parent 9f881c0641
commit b82a4bb2fa

View File

@ -72,8 +72,11 @@ def add_author_stat_columns(q):
# Create a subquery for comments count
sub_comments = (
select(Author.id, func.count(Reaction.id).label('comments_stat'))
.join(
select(
Author.id,
func.coalesce(func.count(Reaction.id), 0).label('comments_stat')
)
.outerjoin(
Reaction,
and_(
Reaction.created_by == Author.id,