This commit is contained in:
parent
28f1f1cc57
commit
9c804bc873
|
@ -92,6 +92,9 @@ async def unfollow(_, info, what, slug):
|
||||||
@login_required
|
@login_required
|
||||||
async def get_my_followed(_, info):
|
async def get_my_followed(_, info):
|
||||||
user_id = info.context["user_id"]
|
user_id = info.context["user_id"]
|
||||||
|
topics = []
|
||||||
|
authors = []
|
||||||
|
communities = []
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author = session.query(Author).filter(Author.user == user_id).first()
|
author = session.query(Author).filter(Author.user == user_id).first()
|
||||||
if author:
|
if author:
|
||||||
|
@ -101,19 +104,21 @@ async def get_my_followed(_, info):
|
||||||
.filter(AuthorFollower.follower == author.id)
|
.filter(AuthorFollower.follower == author.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
topics_query = select(Topic).join(TopicFollower).filter(TopicFollower.follower == author.id)
|
topics_query = select(Topic).join(TopicFollower, TopicFollower.follower == Author.id)
|
||||||
|
|
||||||
# communities_query = select(Community).join(CommunityAuthor).filter(CommunityAuthor.author == author.id)
|
for [author] in session.execute(authors_query):
|
||||||
|
authors.append(author)
|
||||||
|
|
||||||
|
for [topic] in session.execute(topics_query):
|
||||||
|
topics.append(topic)
|
||||||
|
|
||||||
topics = session.execute(topics_query).all()
|
|
||||||
authors = session.execute(authors_query).all()
|
|
||||||
communities = session.query(Community).all()
|
communities = session.query(Community).all()
|
||||||
|
|
||||||
return {"topics": topics, "authors": authors, "communities": communities}
|
return {"topics": topics, "authors": authors, "communities": communities}
|
||||||
|
|
||||||
|
|
||||||
@query.field("get_shout_followers")
|
@query.field("get_shout_followers")
|
||||||
def get_shout_followers(_, _info, slug: str = "", shout_id: int = None) -> List[Author]:
|
def get_shout_followers(_, _info, slug: str = "", shout_id: int | None = None) -> List[Author]:
|
||||||
followers = []
|
followers = []
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shout = None
|
shout = None
|
||||||
|
|
|
@ -62,7 +62,7 @@ def reactions_follow(author_id, shout_id, auto=False):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def reactions_unfollow(author_id: int, shout_id: int):
|
def reactions_unfollow(author_id, shout_id: int):
|
||||||
try:
|
try:
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shout = session.query(Shout).where(Shout.id == shout_id).one()
|
shout = session.query(Shout).where(Shout.id == shout_id).one()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user