comments-stat-off-2
All checks were successful
Deploy on push / deploy (push) Successful in 24s

This commit is contained in:
Untone 2024-02-26 01:24:32 +03:00
parent 90a6e23e61
commit 8635fd9c08

View File

@ -1,4 +1,4 @@
from sqlalchemy import func, distinct, select, join, and_, case, true, cast, Integer, literal from sqlalchemy import func, distinct, select, join, and_, case, true, cast, Integer
from sqlalchemy.orm import aliased from sqlalchemy.orm import aliased
from orm.reaction import Reaction, ReactionKind from orm.reaction import Reaction, ReactionKind
@ -77,18 +77,17 @@ def add_author_stat_columns(q):
'followers_stat' 'followers_stat'
) )
) )
# FIXME: author.stat.comments # .add_columns(literal('0')).label('comments_count')
#.outerjoin(aliased_reaction) )
.add_columns(
literal('0') # FIXME: author.stat.comments
#func.count(distinct(aliased_reaction.id)).filter( #.outerjoin(aliased_reaction)
# and_( #func.count(distinct(aliased_reaction.id)).filter(
# aliased_reaction.created_by == Author.id, # and_(
# aliased_reaction.kind == ReactionKind.COMMENT.value, # aliased_reaction.created_by == Author.id,
# aliased_reaction.deleted_at.is_(None), # aliased_reaction.kind == ReactionKind.COMMENT.value,
# ) # aliased_reaction.deleted_at.is_(None),
).label('comments_count') # )
)
q = q.group_by(Author.id) q = q.group_by(Author.id)
@ -168,7 +167,7 @@ def get_with_stat(q):
entity = cols[0] entity = cols[0]
entity.stat = {'shouts': cols[1], 'authors': cols[2], 'followers': cols[3]} entity.stat = {'shouts': cols[1], 'authors': cols[2], 'followers': cols[3]}
if is_author: if is_author:
entity.stat['comments'] = cols[4] entity.stat['comments'] = 0 # FIXME: cols[4]
# entity.stat['rating'] = cols[5] - cols[6] # entity.stat['rating'] = cols[5] - cols[6]
# entity.stat['rating_shouts'] = cols[7] - cols[8] # entity.stat['rating_shouts'] = cols[7] - cols[8]
pass pass