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

View File

@ -25,3 +25,4 @@ DateTime~=4.7
asyncio~=3.4.3
python-dateutil~=2.8.2
beautifulsoup4~=4.11.1
lxml

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()
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 = []

View File

@ -182,7 +182,7 @@ class ReactedStorage:
await self.recount(siblings)
print("[stat.reacted] %d reactions recounted" % c)
print("[stat.reacted] %d shouts" % len(self.modified_shouts))
print("[stat.reacted] %d shouts modified" % len(self.modified_shouts))
print("[stat.reacted] %d topics" % len(self.reacted["topics"].values()))
print("[stat.reacted] %d authors" % len(self.reacted["authors"].values()))
print("[stat.reacted] %d replies" % len(self.reacted["reactions"]))

View File

@ -1,12 +0,0 @@
from base.orm import local_session
from orm.user import User
from orm.shout import ShoutAuthor
class AuthorsStorage:
@staticmethod
async def get_all_authors():
with local_session() as session:
query = session.query(User).join(ShoutAuthor)
result = query.all()
return result