shoutsRatedByUser only for auth user
This commit is contained in:
parent
6919b2603c
commit
86383cb6c0
|
@ -490,12 +490,18 @@ async def shouts_commented_by_user(_, info, slug, page, size):
|
|||
return shouts
|
||||
|
||||
@query.field("shoutsRatedByUser")
|
||||
async def shouts_rated_by_user(_, info, slug, page, size):
|
||||
@login_required
|
||||
async def shouts_rated_by_user(_, info, page, size):
|
||||
user = info.context["request"].user
|
||||
|
||||
with local_session() as session:
|
||||
shouts = session.query(Shout).\
|
||||
join(ShoutRating).\
|
||||
where(ShoutRating.rater == slug).\
|
||||
where(ShoutRating.rater == user.slug).\
|
||||
order_by(desc(ShoutRating.ts)).\
|
||||
limit(size).\
|
||||
offset( (page - 1) * size)
|
||||
return shouts
|
||||
|
||||
return {
|
||||
"shouts" : shouts
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ type ShoutResult {
|
|||
shout: Shout
|
||||
}
|
||||
|
||||
type ShoutsResult {
|
||||
error: String
|
||||
shouts: [Shout]
|
||||
}
|
||||
|
||||
type CommentResult {
|
||||
error: String
|
||||
comment: Comment
|
||||
|
@ -140,8 +145,8 @@ type Query {
|
|||
userSubscribers(slug: String!): [User]!
|
||||
userSubscribedTopics(slug: String!): [String]!
|
||||
|
||||
shoutsRatedByUser(page: Int!, size: Int!): ShoutsResult!
|
||||
shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
|
||||
shoutsRatedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
|
||||
|
||||
# shouts
|
||||
getShoutBySlug(slug: String!): Shout!
|
||||
|
|
Loading…
Reference in New Issue
Block a user