yet a bit more refactoring
This commit is contained in:
1 parent
eeda497f97
commit
676e7619d8
6 files changed
+24
-24
No files matched your search
@@ -12,13 +12,13 @@ const args = {
|
||||
description: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { codeName, title, description }, context) => {
|
||||
// let authIdOnSession = context.user.sub
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: args.codeName }).exec((err, competition) => {
|
||||
Competition.findOne({ codeName }).exec((err, competition) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
if (competition.rules.some(rule => rule.title === args.title)) {
|
||||
if (competition.rules.some(rule => rule.title === title)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(competition)
|
||||
} else {
|
||||
@@ -28,8 +28,8 @@ const resolve = (parent, args, context) => {
|
||||
}
|
||||
competition.rules.push({
|
||||
number,
|
||||
title: args.title,
|
||||
description: args.description
|
||||
title,
|
||||
description
|
||||
})
|
||||
competition.save((err) => {
|
||||
if (err) reject(err)
|
||||
|
||||
@@ -15,16 +15,16 @@ const args = {
|
||||
formula: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { displayName, description, startDatetime, finishDatetime, formula }, context) => {
|
||||
// let authIdOnSession = context.user.sub
|
||||
let authIdOnSession = 'some-id'
|
||||
let newCompetition = new Competition({
|
||||
host: authIdOnSession,
|
||||
displayName: args.displayName,
|
||||
description: args.description,
|
||||
startDatetime: args.startDatetime,
|
||||
finishDatetime: args.finishDatetime,
|
||||
formula: args.formula
|
||||
displayName,
|
||||
description,
|
||||
startDatetime,
|
||||
finishDatetime,
|
||||
formula
|
||||
})
|
||||
newCompetition.codeName = slugify(newCompetition.displayName) + '-' + newCompetition._id
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -13,10 +13,10 @@ const args = {
|
||||
release: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { codeName, devTeam, bot, release }, context) => {
|
||||
// let authIdOnSession = context.user.sub
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: args.codeName }).exec((err, competition) => {
|
||||
Competition.findOne({ codeName }).exec((err, competition) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
if (competition.participants.some(participant => participant.devTeam === args.devTeam)) {
|
||||
@@ -24,9 +24,9 @@ const resolve = (parent, args, context) => {
|
||||
resolve(competition)
|
||||
} else {
|
||||
competition.participants.push({
|
||||
devTeam: args.devTeam,
|
||||
bot: args.bot,
|
||||
release: args.release
|
||||
devTeam,
|
||||
bot,
|
||||
release
|
||||
})
|
||||
competition.save((err) => {
|
||||
if (err) reject(err)
|
||||
|
||||
@@ -10,11 +10,11 @@ const args = {
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{},
|
||||
args.includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ const args = {
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { devTeam, includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{
|
||||
participants: { $elemMatch: { devTeam: args.devTeam } }
|
||||
participants: { $elemMatch: { devTeam } }
|
||||
},
|
||||
args.includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ const args = {
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { host, includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{
|
||||
host: args.host
|
||||
host
|
||||
},
|
||||
args.includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
includeOld ? { finishDatetime: { $gt: epoch() } } : {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user