add shoutsRatedByUser

This commit is contained in:
knst-kotov 2022-04-28 12:36:48 +03:00
parent f07780895e
commit 9fab68fc29
2 changed files with 12 additions and 0 deletions

View File

@ -488,3 +488,14 @@ async def shouts_commented_by_user(_, info, slug, page, size):
limit(size).\
offset( (page - 1) * size)
return shouts
@query.field("shoutsRatedByUser")
async def shouts_rated_by_user(_, info, slug, page, size):
with local_session() as session:
shouts = session.query(Shout).\
join(ShoutRating).\
where(ShoutRating.rater == slug).\
order_by(desc(ShoutRating.ts)).\
limit(size).\
offset( (page - 1) * size)
return shouts

View File

@ -141,6 +141,7 @@ type Query {
userSubscribedTopics(slug: String!): [Topic]!
shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
shoutsRatedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
# shouts
getShoutBySlug(slug: String!): Shout!