shouts-author-stat
This commit is contained in:
@@ -9,11 +9,10 @@ from base.resolvers import mutation, query
|
||||
from orm.reaction import Reaction
|
||||
from orm.topic import Topic, TopicFollower
|
||||
from orm.user import AuthorFollower, Role, User, UserRating, UserRole
|
||||
from services.auth.users import UserStorage
|
||||
from services.stat.reacted import ReactedStorage
|
||||
from services.stat.topicstat import TopicStat
|
||||
from services.zine.authors import AuthorsStorage
|
||||
from services.zine.shoutauthor import ShoutAuthorStorage
|
||||
from services.zine.shoutauthor import ShoutAuthor
|
||||
|
||||
# from .community import followed_communities
|
||||
from .inbox.load import get_total_unread_counter
|
||||
@@ -34,6 +33,7 @@ async def get_author_stat(slug):
|
||||
# TODO: implement author stat
|
||||
with local_session() as session:
|
||||
return {
|
||||
"shouts": session.query(ShoutAuthor).where(ShoutAuthor.author == slug).count(),
|
||||
"followers": session.query(AuthorFollower).where(AuthorFollower.author == slug).count(),
|
||||
"followings": session.query(AuthorFollower).where(AuthorFollower.follower == slug).count(),
|
||||
"rating": session.query(func.sum(UserRating.value)).where(UserRating.user == slug).first(),
|
||||
|
@@ -1,8 +1,6 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from sqlalchemy import and_, desc, select, text, func
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
from auth.authenticate import login_required
|
||||
from base.orm import local_session
|
||||
from base.resolvers import mutation, query
|
||||
@@ -14,7 +12,7 @@ from services.stat.reacted import ReactedStorage
|
||||
|
||||
async def get_reaction_stat(reaction_id):
|
||||
return {
|
||||
# "viewed": await ViewStat.get_reaction(reaction_id),
|
||||
# "viewed": await ViewedStorage.get_reaction(reaction_id),
|
||||
"reacted": len(await ReactedStorage.get_reaction(reaction_id)),
|
||||
"rating": await ReactedStorage.get_reaction_rating(reaction_id),
|
||||
"commented": len(await ReactedStorage.get_reaction_comments(reaction_id)),
|
||||
|
@@ -9,7 +9,7 @@ from orm.topic import Topic, TopicFollower
|
||||
from services.zine.topics import TopicStorage
|
||||
from services.stat.reacted import ReactedStorage
|
||||
from services.stat.topicstat import TopicStat
|
||||
from services.stat.views import ViewStat
|
||||
from services.stat.viewed import ViewedStorage
|
||||
|
||||
|
||||
async def get_topic_stat(slug):
|
||||
@@ -17,7 +17,7 @@ async def get_topic_stat(slug):
|
||||
"shouts": len(TopicStat.shouts_by_topic.get(slug, {}).keys()),
|
||||
"authors": len(TopicStat.authors_by_topic.get(slug, {}).keys()),
|
||||
"followers": len(TopicStat.followers_by_topic.get(slug, {}).keys()),
|
||||
"viewed": await ViewStat.get_topic(slug),
|
||||
"viewed": await ViewedStorage.get_topic(slug),
|
||||
"reacted": len(await ReactedStorage.get_topic(slug)),
|
||||
"commented": len(await ReactedStorage.get_topic_comments(slug)),
|
||||
"rating": await ReactedStorage.get_topic_rating(slug)
|
||||
|
Reference in New Issue
Block a user