From 77d8e2f2fd4be32d0c582bdfeeb5ccac9c194c41 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Mon, 28 Nov 2022 16:15:52 +0300 Subject: [PATCH] pushed-wip --- resolvers/zine/reactions.py | 12 ++++-------- schema.graphql | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/resolvers/zine/reactions.py b/resolvers/zine/reactions.py index 3f4fccf1..f071a93e 100644 --- a/resolvers/zine/reactions.py +++ b/resolvers/zine/reactions.py @@ -201,11 +201,10 @@ async def delete_reaction(_, info, rid): def map_result_item(result_item): - [user, shout, reaction] = result_item + [reaction, user, shout] = result_item print(reaction) reaction.createdBy = user reaction.shout = shout - reaction.replyTo = reaction return reaction @@ -229,15 +228,12 @@ async def load_reactions_by(_, _info, by, limit=50, offset=0): CreatedByUser = aliased(User) ReactedShout = aliased(Shout) - RepliedReaction = aliased(Reaction) q = select( - Reaction, CreatedByUser, ReactedShout, RepliedReaction + Reaction, CreatedByUser, ReactedShout ).join( CreatedByUser, Reaction.createdBy == CreatedByUser.slug ).join( ReactedShout, Reaction.shout == ReactedShout.slug - ).join( - RepliedReaction, Reaction.replyTo == RepliedReaction.id ) if by.get("shout"): @@ -268,10 +264,10 @@ async def load_reactions_by(_, _info, by, limit=50, offset=0): reactions = [] with local_session() as session: for [ - [reaction, rating, commented, reacted], shout, reply + [reaction, rating, commented, reacted], user, shout ] in list(map(map_result_item, session.execute(q))): + reaction.createdBy = user reaction.shout = shout - reaction.replyTo = reply reaction.stat = { "rating": rating, "commented": commented, diff --git a/schema.graphql b/schema.graphql index b61f7b43..9933cb35 100644 --- a/schema.graphql +++ b/schema.graphql @@ -152,7 +152,7 @@ type Mutation { updateChat(chat: ChatInput!): Result! deleteChat(chatId: String!): Result! - createMessage(chat: String!, body: String!, replyTo: String): Result! + createMessage(chat: String!, body: String!, replyTo: Int): Result! updateMessage(chatId: String!, id: Int!, body: String!): Result! deleteMessage(chatId: String!, id: Int!): Result! markAsRead(chatId: String!, ids: [Int]!): Result! @@ -410,7 +410,7 @@ type Reaction { range: String # full / 0:2340 kind: ReactionKind! body: String - replyTo: Reaction + replyTo: Int stat: Stat old_id: String old_thread: String