-storage
This commit is contained in:
parent
ebb3fe211d
commit
df224fc209
|
@ -25,3 +25,4 @@ DateTime~=4.7
|
||||||
asyncio~=3.4.3
|
asyncio~=3.4.3
|
||||||
python-dateutil~=2.8.2
|
python-dateutil~=2.8.2
|
||||||
beautifulsoup4~=4.11.1
|
beautifulsoup4~=4.11.1
|
||||||
|
lxml
|
||||||
|
|
|
@ -11,7 +11,6 @@ from orm.topic import Topic, TopicFollower
|
||||||
from orm.user import AuthorFollower, Role, User, UserRating, UserRole
|
from orm.user import AuthorFollower, Role, User, UserRating, UserRole
|
||||||
from services.stat.reacted import ReactedStorage
|
from services.stat.reacted import ReactedStorage
|
||||||
from services.stat.topicstat import TopicStat
|
from services.stat.topicstat import TopicStat
|
||||||
from services.zine.authors import AuthorsStorage
|
|
||||||
from services.zine.shoutauthor import ShoutAuthor
|
from services.zine.shoutauthor import ShoutAuthor
|
||||||
|
|
||||||
# from .community import followed_communities
|
# from .community import followed_communities
|
||||||
|
@ -175,12 +174,22 @@ def author_unfollow(user, slug):
|
||||||
|
|
||||||
@query.field("authorsAll")
|
@query.field("authorsAll")
|
||||||
async def get_authors_all(_, _info):
|
async def get_authors_all(_, _info):
|
||||||
authors = await AuthorsStorage.get_all_authors()
|
with local_session() as session:
|
||||||
for author in authors:
|
authors = session.query(User).join(ShoutAuthor).all()
|
||||||
author.stat = await get_author_stat(author.slug)
|
for author in authors:
|
||||||
|
author.stat = await get_author_stat(author.slug)
|
||||||
return authors
|
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")
|
@query.field("loadAuthorsBy")
|
||||||
async def load_authors_by(_, info, by, limit, offset):
|
async def load_authors_by(_, info, by, limit, offset):
|
||||||
authors = []
|
authors = []
|
||||||
|
|
|
@ -182,7 +182,7 @@ class ReactedStorage:
|
||||||
await self.recount(siblings)
|
await self.recount(siblings)
|
||||||
|
|
||||||
print("[stat.reacted] %d reactions recounted" % c)
|
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 topics" % len(self.reacted["topics"].values()))
|
||||||
print("[stat.reacted] %d authors" % len(self.reacted["authors"].values()))
|
print("[stat.reacted] %d authors" % len(self.reacted["authors"].values()))
|
||||||
print("[stat.reacted] %d replies" % len(self.reacted["reactions"]))
|
print("[stat.reacted] %d replies" % len(self.reacted["reactions"]))
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user