comments-counter-fix
Some checks failed
Deploy on push / deploy (push) Failing after 9s

This commit is contained in:
Untone 2024-08-09 07:44:23 +03:00
parent 56f1506450
commit 71db929fa4
2 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ def add_reaction_stat_columns(q, aliased_reaction):
# Присоединение реакций и добавление статистических колонок # Присоединение реакций и добавление статистических колонок
q = q.outerjoin(aliased_reaction, aliased_reaction.deleted_at.is_(None)).add_columns( 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.count().filter(aliased_reaction.kind == ReactionKind.COMMENT.value).label("comments_stat"),
# Вычисление рейтинга как разница между лайками и дизлайками # Вычисление рейтинга как разница между лайками и дизлайками
func.sum( func.sum(
case( case(

View File

@ -83,7 +83,7 @@ def query_shouts(slug=None):
q = ( q = (
select( select(
Shout, Shout,
func.count(case((aliased_reaction.body.is_not(None), 1))).label("comments_stat"), func.count().filter(aliased_reaction.kind == ReactionKind.COMMENT.value).label("comments_stat"),
func.count(distinct(ShoutReactionsFollower.follower)).label("followers_stat"), func.count(distinct(ShoutReactionsFollower.follower)).label("followers_stat"),
func.sum( func.sum(
case( case(
@ -178,7 +178,7 @@ def get_shouts_with_stats(q, limit, offset=0, author_id=None):
shout.topics = parse_aggregated_string(topics, Topic) shout.topics = parse_aggregated_string(topics, Topic)
shout.stat = { shout.stat = {
"viewed": ViewedStorage.get_shout(shout.id), "viewed": ViewedStorage.get_shout(shout.id),
"followers": followers_stat or 0, "followed": followers_stat or 0,
"rating": rating_stat or 0, "rating": rating_stat or 0,
"commented": comments_stat or 0, "commented": comments_stat or 0,
"last_reacted_at": last_reacted_at, "last_reacted_at": last_reacted_at,