add userUnpublishedShouts

This commit is contained in:
knst-kotov 2022-04-29 11:27:34 +03:00
parent 86383cb6c0
commit d7cbe150d6
2 changed files with 18 additions and 0 deletions

View File

@ -505,3 +505,20 @@ async def shouts_rated_by_user(_, info, page, size):
return {
"shouts" : shouts
}
@query.field("userUnpublishedShouts")
@login_required
async def user_unpublished_shouts(_, info, page, size):
user = info.context["request"].user
with local_session() as session:
shouts = session.query(Shout).\
join(ShoutAuthor).\
where(and_(Shout.publishedAt == None, ShoutAuthor.user == user.slug)).\
order_by(desc(Shout.createdAt)).\
limit(size).\
offset( (page - 1) * size)
return {
"shouts" : shouts
}

View File

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