add shoutsCommentedByUser
This commit is contained in:
parent
cca6f8cec3
commit
f07780895e
|
@ -473,3 +473,18 @@ async def shouts_candidates(_, info, size):
|
||||||
limit(size)
|
limit(size)
|
||||||
|
|
||||||
return shouts
|
return shouts
|
||||||
|
|
||||||
|
@query.field("shoutsCommentedByUser")
|
||||||
|
async def shouts_commented_by_user(_, info, slug, page, size):
|
||||||
|
user = await UserStorage.get_user_by_slug(slug)
|
||||||
|
if not user:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
with local_session() as session:
|
||||||
|
shouts = session.query(Shout).\
|
||||||
|
join(Comment).\
|
||||||
|
where(Comment.author == user.id).\
|
||||||
|
order_by(desc(Comment.createdAt)).\
|
||||||
|
limit(size).\
|
||||||
|
offset( (page - 1) * size)
|
||||||
|
return shouts
|
||||||
|
|
|
@ -140,6 +140,8 @@ type Query {
|
||||||
userSubscribers(slug: String!): [User]!
|
userSubscribers(slug: String!): [User]!
|
||||||
userSubscribedTopics(slug: String!): [Topic]!
|
userSubscribedTopics(slug: String!): [Topic]!
|
||||||
|
|
||||||
|
shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
|
||||||
|
|
||||||
# shouts
|
# shouts
|
||||||
getShoutBySlug(slug: String!): Shout!
|
getShoutBySlug(slug: String!): Shout!
|
||||||
shoutsByTopic(topic: String!, page: Int!, size: Int!): [Shout]!
|
shoutsByTopic(topic: String!, page: Int!, size: Int!): [Shout]!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user