This commit is contained in:
parent
20f7c22441
commit
13ba5ebaed
|
@ -2,6 +2,7 @@
|
||||||
- schema: Reaction.range -> Reaction.quote
|
- schema: Reaction.range -> Reaction.quote
|
||||||
- resolvers: queries and mutations revision and renaming
|
- resolvers: queries and mutations revision and renaming
|
||||||
- resolvers: delete_topic(slug) implemented
|
- resolvers: delete_topic(slug) implemented
|
||||||
|
- resolvers: added get_shout_followers
|
||||||
|
|
||||||
[0.2.15]
|
[0.2.15]
|
||||||
- schema: Shout.created_by removed
|
- schema: Shout.created_by removed
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
from orm.community import Community, CommunityAuthor as CommunityFollower
|
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 orm.topic import Topic, TopicFollower
|
||||||
from services.auth import login_required
|
from services.auth import login_required
|
||||||
from resolvers.author import author_follow, author_unfollow
|
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):
|
for [c] in session.execute(communities_query):
|
||||||
communities.append(c)
|
communities.append(c)
|
||||||
return {"topics": topics, "authors": authors, "communities": communities}
|
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
|
||||||
|
|
|
@ -304,9 +304,6 @@ type Mutation {
|
||||||
follow(what: FollowingEntity!, slug: String!): Result!
|
follow(what: FollowingEntity!, slug: String!): Result!
|
||||||
unfollow(what: FollowingEntity!, slug: String!): Result!
|
unfollow(what: FollowingEntity!, slug: String!): Result!
|
||||||
|
|
||||||
# FIXME!
|
|
||||||
updateOnlineStatus: Result!
|
|
||||||
|
|
||||||
# topic
|
# topic
|
||||||
create_topic(input: TopicInput!): Result!
|
create_topic(input: TopicInput!): Result!
|
||||||
update_topic(input: TopicInput!): Result!
|
update_topic(input: TopicInput!): Result!
|
||||||
|
@ -338,6 +335,7 @@ type Query {
|
||||||
|
|
||||||
# follower
|
# follower
|
||||||
get_my_followed: Result # { authors topics communities }
|
get_my_followed: Result # { authors topics communities }
|
||||||
|
get_shout_followers(slug: String, shout_id: Int): [Author]
|
||||||
|
|
||||||
# reaction
|
# reaction
|
||||||
load_reactions_by(by: ReactionBy!, limit: Int, offset: Int): [Reaction]
|
load_reactions_by(by: ReactionBy!, limit: Int, offset: Int): [Reaction]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user