authors-stats-fix2
Some checks failed
Deploy on push / deploy (push) Failing after 3m33s

This commit is contained in:
2025-08-31 22:54:40 +03:00
parent e63517a887
commit 7258ddf059
2 changed files with 34 additions and 41 deletions

View File

@@ -413,8 +413,14 @@ async def create_reaction(_: None, info: GraphQLResolveInfo, reaction: dict) ->
shout = session.query(Shout).where(Shout.id == shout_id).first()
if not shout:
return {"error": "Shout not found"}
# Получаем полного автора из БД вместо неполного из контекста
author = session.query(Author).where(Author.id == author_id).first()
if not author:
return {"error": "Author not found"}
rdict["shout"] = shout.dict()
rdict["created_by"] = author_dict
rdict["created_by"] = author.dict()
return {"reaction": rdict}
except Exception as e:
traceback.print_exc()
@@ -470,7 +476,10 @@ async def update_reaction(_: None, info: GraphQLResolveInfo, reaction: dict) ->
await notify_reaction(r, "update")
return {"reaction": r.dict()}
# Включаем полную информацию об авторе в ответ
reaction_dict = r.dict()
reaction_dict["created_by"] = author.dict()
return {"reaction": reaction_dict}
return {"error": "Reaction not found"}
except Exception as e:
logger.error(f"{type(e).__name__}: {e}")
@@ -527,7 +536,13 @@ async def delete_reaction(_: None, info: GraphQLResolveInfo, reaction_id: int) -
await notify_reaction(r, "delete")
return {"error": None, "reaction": r.dict()}
# Включаем полную информацию об авторе в ответ
reaction_dict = r.dict()
reaction_author: Author | None = session.query(Author).where(Author.id == r.created_by).first()
if reaction_author:
reaction_dict["created_by"] = reaction_author.dict()
return {"error": None, "reaction": reaction_dict}
except Exception as e:
logger.error(f"{type(e).__name__}: {e}")
return {"error": "Cannot delete reaction"}