This commit is contained in:
2022-11-21 07:36:40 +03:00
parent ebb3fe211d
commit df224fc209
4 changed files with 15 additions and 17 deletions

View File

@@ -11,7 +11,6 @@ from orm.topic import Topic, TopicFollower
from orm.user import AuthorFollower, Role, User, UserRating, UserRole
from services.stat.reacted import ReactedStorage
from services.stat.topicstat import TopicStat
from services.zine.authors import AuthorsStorage
from services.zine.shoutauthor import ShoutAuthor
# from .community import followed_communities
@@ -175,12 +174,22 @@ def author_unfollow(user, slug):
@query.field("authorsAll")
async def get_authors_all(_, _info):
authors = await AuthorsStorage.get_all_authors()
for author in authors:
author.stat = await get_author_stat(author.slug)
with local_session() as session:
authors = session.query(User).join(ShoutAuthor).all()
for author in authors:
author.stat = await get_author_stat(author.slug)
return authors
@query.field("getAuthor")
async def get_author(_, _info, slug):
with local_session() as session:
author = session.query(User).join(ShoutAuthor).where(User.slug == slug).first()
for author in author:
author.stat = await get_author_stat(author.slug)
return author
@query.field("loadAuthorsBy")
async def load_authors_by(_, info, by, limit, offset):
authors = []