mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-07 19:55:46 -05:00
usersForVoting endpoint
This commit is contained in:
5
frontend-react/src/components/plus/Voting.js
Normal file
5
frontend-react/src/components/plus/Voting.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import React from "react"
|
||||
|
||||
const Voting = () => {}
|
||||
|
||||
export default Voting
|
||||
@@ -13,6 +13,7 @@ const typeDef = gql`
|
||||
plusInfo: PlusGeneralInfo
|
||||
hasAccess(discord_id: String!, server: String!): Boolean!
|
||||
suggestions: [Suggested!]!
|
||||
usersForVoting: UsersForVoting!
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
@@ -86,6 +87,11 @@ const typeDef = gql`
|
||||
"Average of all scores of the voters for the month 0% to 100%"
|
||||
score: Float!
|
||||
}
|
||||
|
||||
type UsersForVoting {
|
||||
users: [User!]!
|
||||
suggested: [Suggested!]!
|
||||
}
|
||||
`
|
||||
|
||||
const resolvers = {
|
||||
@@ -137,6 +143,36 @@ const resolvers = {
|
||||
voting_ends: null,
|
||||
}
|
||||
},
|
||||
usersForVoting: async (root, args, ctx) => {
|
||||
if (!ctx.user) throw new UserInputError("Not logged in")
|
||||
if (!ctx.user.plus || !ctx.user.plus.membership_status)
|
||||
throw new UserInputError("Not plus server member")
|
||||
const plus_server = ctx.user.plus.membership_status
|
||||
|
||||
const users = await User.find({
|
||||
$or: [
|
||||
{
|
||||
"plus.membership_status": plus_server,
|
||||
},
|
||||
|
||||
{ "plus.vouch_status": plus_server },
|
||||
],
|
||||
}).catch(e => {
|
||||
throw (new Error(),
|
||||
{
|
||||
error: e,
|
||||
})
|
||||
})
|
||||
|
||||
const suggested = await Suggested.find({ plus_server }).catch(e => {
|
||||
throw (new Error(),
|
||||
{
|
||||
error: e,
|
||||
})
|
||||
})
|
||||
|
||||
return { users, suggested }
|
||||
},
|
||||
suggestions: (root, args, ctx) => {
|
||||
if (!ctx.user || !ctx.user.plus) return null
|
||||
const searchCriteria =
|
||||
|
||||
Reference in New Issue
Block a user