some-more-queries
This commit is contained in:
@@ -143,11 +143,26 @@ async def get_followed_authors(_, _info, slug) -> List[User]:
|
||||
return await followed_authors(user_id)
|
||||
|
||||
|
||||
@query.field("authorFollowedAuthors")
|
||||
async def get_followed_authors2(_, info, author_id) -> List[User]:
|
||||
return await followed_authors(author_id)
|
||||
@query.field("authorFollowings")
|
||||
async def author_followings(_, info, author_id: int, limit: int = 20, offset: int = 0) -> List[User]:
|
||||
return await followed_authors(author_id)[offset:(limit+offset)]
|
||||
|
||||
|
||||
@query.field("authorFollowers")
|
||||
async def author_followers(_, info, author_id: int, limit: int = 20, offset: int = 0) -> List[User]:
|
||||
|
||||
q = select(User)
|
||||
q = add_author_stat_columns(q)
|
||||
|
||||
aliased_user = aliased(User)
|
||||
q = (
|
||||
q.join(AuthorFollower, AuthorFollower.follower == User.id)
|
||||
.join(aliased_user, aliased_user.id == AuthorFollower.author)
|
||||
.where(aliased_user.id == author_id)
|
||||
)
|
||||
|
||||
return get_authors_from_query(q)
|
||||
|
||||
# 2. Now, we can use the user_id to get the followed authors
|
||||
async def followed_authors(user_id):
|
||||
q = select(User)
|
||||
|
Reference in New Issue
Block a user