typingsfix
This commit is contained in:
parent
2ff715eb50
commit
817002b17b
|
@ -38,7 +38,7 @@ class Reaction(Base):
|
|||
oid: str = Column(String, nullable=True, comment="Old ID")
|
||||
|
||||
@property
|
||||
async def stat(self) -> dict:
|
||||
async def stat(self) -> Dict:
|
||||
reacted = 0
|
||||
try:
|
||||
with local_session() as session:
|
||||
|
|
|
@ -61,7 +61,7 @@ class Shout(Base):
|
|||
oid: str = Column(String, nullable=True)
|
||||
|
||||
@property
|
||||
async def stat(self) -> dict:
|
||||
async def stat(self) -> Dict:
|
||||
return {
|
||||
"viewed": await ViewedStorage.get_shout(self.slug),
|
||||
"reacted": await ReactionsStorage.by_shout(self.slug)
|
||||
|
|
|
@ -4,7 +4,7 @@ from orm.user import User
|
|||
from resolvers.base import mutation, query
|
||||
from auth.authenticate import login_required
|
||||
from datetime import datetime
|
||||
|
||||
from typing import List
|
||||
from sqlalchemy import and_
|
||||
|
||||
@mutation.field("createCommunity")
|
||||
|
@ -92,7 +92,7 @@ def community_unfollow(user, slug):
|
|||
session.commit()
|
||||
|
||||
@query.field("userFollowedCommunities")
|
||||
def get_followed_communities(_, user_slug) -> list[Community]:
|
||||
def get_followed_communities(_, user_slug) -> List[Community]:
|
||||
ccc = []
|
||||
with local_session() as session:
|
||||
ccc = session.query(Community.slug).\
|
||||
|
|
|
@ -5,10 +5,11 @@ from orm.reaction import Reaction
|
|||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
from orm.topic import TopicFollower
|
||||
from orm.user import AuthorFollower
|
||||
from typing import List
|
||||
|
||||
@query.field("shoutsForFeed")
|
||||
@login_required
|
||||
def get_user_feed(_, info, page, size) -> list[Shout]:
|
||||
def get_user_feed(_, info, page, size) -> List[Shout]:
|
||||
user = info.context["request"].user
|
||||
shouts = []
|
||||
with local_session() as session:
|
||||
|
@ -27,7 +28,7 @@ def get_user_feed(_, info, page, size) -> list[Shout]:
|
|||
|
||||
@query.field("myCandidates")
|
||||
@login_required
|
||||
async def user_unpublished_shouts(_, info, page = 1, size = 10) -> list[Shout]:
|
||||
async def user_unpublished_shouts(_, info, page = 1, size = 10) -> List[Shout]:
|
||||
user = info.context["request"].user
|
||||
shouts = []
|
||||
with local_session() as session:
|
||||
|
|
|
@ -11,10 +11,10 @@ from auth.authenticate import login_required
|
|||
from inbox_resolvers.inbox import get_inbox_counter
|
||||
from sqlalchemy import and_, desc
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
from typing import List
|
||||
|
||||
@query.field("userReactedShouts")
|
||||
async def get_user_reacted_shouts(_, info, slug, page, size) -> list[Shout]:
|
||||
async def get_user_reacted_shouts(_, info, slug, page, size) -> List[Shout]:
|
||||
user = await UserStorage.get_user_by_slug(slug)
|
||||
if not user: return {}
|
||||
with local_session() as session:
|
||||
|
@ -29,7 +29,7 @@ async def get_user_reacted_shouts(_, info, slug, page, size) -> list[Shout]:
|
|||
|
||||
@query.field("userFollowedTopics")
|
||||
@login_required
|
||||
def get_followed_topics(_, slug) -> list[Topic]:
|
||||
def get_followed_topics(_, slug) -> List[Topic]:
|
||||
rows = []
|
||||
with local_session() as session:
|
||||
rows = session.query(Topic).\
|
||||
|
@ -40,7 +40,7 @@ def get_followed_topics(_, slug) -> list[Topic]:
|
|||
|
||||
|
||||
@query.field("userFollowedAuthors")
|
||||
def get_followed_authors(_, slug) -> list[User]:
|
||||
def get_followed_authors(_, slug) -> List[User]:
|
||||
authors = []
|
||||
with local_session() as session:
|
||||
authors = session.query(User).\
|
||||
|
@ -51,7 +51,7 @@ def get_followed_authors(_, slug) -> list[User]:
|
|||
|
||||
|
||||
@query.field("userFollowers")
|
||||
async def user_followers(_, slug) -> list[User]:
|
||||
async def user_followers(_, slug) -> List[User]:
|
||||
with local_session() as session:
|
||||
users = session.query(User).\
|
||||
join(AuthorFollower, User.slug == AuthorFollower.follower).\
|
||||
|
|
|
@ -9,7 +9,7 @@ from auth.authenticate import login_required
|
|||
from datetime import datetime
|
||||
from storages.reactions import ReactionsStorage
|
||||
from storages.viewed import ViewedStorage
|
||||
|
||||
from typing import List
|
||||
|
||||
def reactions_follow(user, slug, auto=False):
|
||||
with local_session() as session:
|
||||
|
@ -104,7 +104,7 @@ async def delete_reaction(_, info, id):
|
|||
return {}
|
||||
|
||||
@query.field("reactionsByShout")
|
||||
def get_shout_reactions(_, info, slug) -> list[Shout]:
|
||||
def get_shout_reactions(_, info, slug) -> List[Shout]:
|
||||
shouts = []
|
||||
with local_session() as session:
|
||||
shoutslugs = session.query(ShoutReactionsFollower.shout).\
|
||||
|
@ -117,7 +117,7 @@ def get_shout_reactions(_, info, slug) -> list[Shout]:
|
|||
|
||||
|
||||
@query.field("reactionsAll")
|
||||
def get_all_reactions(_, info, page=1, size=10) -> list[Reaction]:
|
||||
def get_all_reactions(_, info, page=1, size=10) -> List[Reaction]:
|
||||
reactions = []
|
||||
with local_session() as session:
|
||||
q = session.query(Reaction).\
|
||||
|
@ -134,7 +134,7 @@ def get_all_reactions(_, info, page=1, size=10) -> list[Reaction]:
|
|||
|
||||
|
||||
@query.field("reactionsByAuthor")
|
||||
def get_reactions_by_author(_, info, slug, page=1, size=50) -> list[Reaction]:
|
||||
def get_reactions_by_author(_, info, slug, page=1, size=50) -> List[Reaction]:
|
||||
reactions = []
|
||||
with local_session() as session:
|
||||
reactions = session.query(Reaction).\
|
||||
|
|
|
@ -4,7 +4,7 @@ import asyncio
|
|||
from orm.base import local_session
|
||||
from storages.shoutauthor import ShoutAuthorStorage
|
||||
from orm.topic import ShoutTopic, TopicFollower
|
||||
|
||||
from typing import Dict
|
||||
|
||||
class TopicStat:
|
||||
shouts_by_topic = {}
|
||||
|
@ -55,7 +55,7 @@ class TopicStat:
|
|||
return self.shouts_by_topic.get(topic, [])
|
||||
|
||||
@staticmethod
|
||||
async def get_stat(topic) -> dict:
|
||||
async def get_stat(topic) -> Dict:
|
||||
self = TopicStat
|
||||
async with self.lock:
|
||||
shouts = self.shouts_by_topic.get(topic, [])
|
||||
|
|
Loading…
Reference in New Issue
Block a user