add shoutsCommentedByUser

This commit is contained in:
knst-kotov 2022-04-28 12:04:14 +03:00
parent cca6f8cec3
commit f07780895e
2 changed files with 17 additions and 0 deletions

View File

@ -473,3 +473,18 @@ async def shouts_candidates(_, info, size):
limit(size)
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

View File

@ -140,6 +140,8 @@ type Query {
userSubscribers(slug: String!): [User]!
userSubscribedTopics(slug: String!): [Topic]!
shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
# shouts
getShoutBySlug(slug: String!): Shout!
shoutsByTopic(topic: String!, page: Int!, size: Int!): [Shout]!