This commit is contained in:
@@ -27,10 +27,8 @@ def add_reaction_stat_columns(q, aliased_reaction):
|
||||
"""
|
||||
# Присоединение реакций и добавление статистических колонок
|
||||
q = q.outerjoin(aliased_reaction, aliased_reaction.deleted_at.is_(None)).add_columns(
|
||||
|
||||
# Подсчет комментариев
|
||||
func.count(case((aliased_reaction.body.is_not(None), 1), else_=0)).label("comments_stat"),
|
||||
|
||||
# Вычисление рейтинга как разница между лайками и дизлайками
|
||||
func.sum(
|
||||
case(
|
||||
@@ -497,13 +495,7 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
|
||||
reactions = set()
|
||||
with local_session() as session:
|
||||
result_rows = session.execute(q)
|
||||
for [
|
||||
reaction,
|
||||
author,
|
||||
shout,
|
||||
commented_stat,
|
||||
rating_stat
|
||||
] in result_rows:
|
||||
for [reaction, author, shout, commented_stat, rating_stat] in result_rows:
|
||||
reaction.created_by = author
|
||||
reaction.shout = shout
|
||||
reaction.stat = {"rating": rating_stat, "commented": commented_stat}
|
||||
|
Reference in New Issue
Block a user