This commit is contained in:
2023-10-11 11:56:46 +03:00
21 changed files with 651 additions and 254 deletions

View File

@@ -266,10 +266,20 @@ async def get_authors_all(_, _info):
@query.field("getAuthor")
async def get_author(_, _info, slug):
q = select(User).where(User.slug == slug)
q = add_author_stat_columns(q, True)
q = add_author_stat_columns(q)
authors = get_authors_from_query(q)
return authors[0]
[author] = get_authors_from_query(q)
with local_session() as session:
comments_count = session.query(Reaction).where(
and_(
Reaction.createdBy == author.id,
Reaction.kind == ReactionKind.COMMENT
)
).count()
author.stat["commented"] = comments_count
return author
@query.field("loadAuthorsBy")