From 02b504cc4f1fd2d05512ddcf651eba347c38b0c4 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 26 Feb 2024 20:05:07 +0300 Subject: [PATCH] no-distinct --- resolvers/reaction.py | 3 +-- resolvers/stat.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/resolvers/reaction.py b/resolvers/reaction.py index a98e5b02..31838fcf 100644 --- a/resolvers/reaction.py +++ b/resolvers/reaction.py @@ -356,10 +356,9 @@ async def load_reactions_by(_, info, by, limit=50, offset=0): """ q = ( - select(Reaction, Author, Shout) + select([Reaction, Author, Shout]) .join(Author, Reaction.created_by == Author.id) .join(Shout, Reaction.shout == Shout.id) - .distinct() # Применяем DISTINCT здесь ) # calculate counters diff --git a/resolvers/stat.py b/resolvers/stat.py index 7cb2abf9..230501b8 100644 --- a/resolvers/stat.py +++ b/resolvers/stat.py @@ -85,10 +85,10 @@ def add_author_stat_columns(q): # aliased_reaction.kind == ReactionKind.COMMENT.value, # aliased_reaction.deleted_at.is_(None), # ), - #) - #.add_columns( + # ) + # .add_columns( # func.count(distinct(aliased_reaction.id)).label('comments_stat') - #) + # ) q = q.group_by(Author.id) return q