shout-followers
All checks were successful
deploy / deploy (push) Successful in 2m20s

This commit is contained in:
2023-11-28 12:11:45 +03:00
parent 20f7c22441
commit 13ba5ebaed
3 changed files with 23 additions and 3 deletions

View File

@@ -1,6 +1,10 @@
from typing import List
from sqlalchemy import select
from orm.community import Community, CommunityAuthor as CommunityFollower
from orm.reaction import Reaction
from orm.shout import Shout
from orm.topic import Topic, TopicFollower
from services.auth import login_required
from resolvers.author import author_follow, author_unfollow
@@ -114,3 +118,20 @@ async def get_my_followed(_, info):
for [c] in session.execute(communities_query):
communities.append(c)
return {"topics": topics, "authors": authors, "communities": communities}
@query.field("get_shout_followers")
def get_shout_followers(_, _info, slug: str = "", shout_id: int = None) -> List[Author]:
followers = []
with local_session() as session:
shout = None
if slug:
shout = session.query(Shout).filter(Shout.slug == slug).first()
elif shout_id:
shout = session.query(Shout).filter(Shout.id == shout_id).first()
if shout:
reactions = session.query(Reaction).filter(Reaction.shout == shout.id).all()
for r in reactions:
followers.append(r.created_by)
return followers