mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
26ad981dbf
2 changed files with 25 additions and 1 deletions
|
@ -23,6 +23,25 @@ connectToScoringQueue = ->
|
||||||
if error? then throw new Error "There was an error registering the scoring queue: #{error}"
|
if error? then throw new Error "There was an error registering the scoring queue: #{error}"
|
||||||
scoringTaskQueue = data
|
scoringTaskQueue = data
|
||||||
log.info "Connected to scoring task queue!"
|
log.info "Connected to scoring task queue!"
|
||||||
|
|
||||||
|
module.exports.addPairwiseTaskToQueue = (req, res) ->
|
||||||
|
taskPair = req.body.sessions
|
||||||
|
#unless isUserAdmin req then return errors.forbidden res, "You do not have the permissions to submit that game to the leaderboard"
|
||||||
|
#fetch both sessions
|
||||||
|
LevelSession.findOne(_id:taskPair[0]).lean().exec (err, firstSession) =>
|
||||||
|
if err? then return errors.serverError res, "There was an error fetching the first session in the pair"
|
||||||
|
LevelSession.find(_id:taskPair[1]).exec (err, secondSession) =>
|
||||||
|
if err? then return errors.serverError res, "There was an error fetching the second session"
|
||||||
|
try
|
||||||
|
taskPairs = generateTaskPairs(secondSession, firstSession)
|
||||||
|
catch e
|
||||||
|
if e then return errors.serverError res, "There was an error generating the task pairs"
|
||||||
|
|
||||||
|
sendEachTaskPairToTheQueue taskPairs, (taskPairError) ->
|
||||||
|
if taskPairError? then return errors.serverError res, "There was an error sending the task pairs to the queue"
|
||||||
|
|
||||||
|
sendResponseObject req, res, {"message":"All task pairs were succesfully sent to the queue"}
|
||||||
|
|
||||||
|
|
||||||
module.exports.createNewTask = (req, res) ->
|
module.exports.createNewTask = (req, res) ->
|
||||||
requestSessionID = req.body.session
|
requestSessionID = req.body.session
|
||||||
|
|
|
@ -6,9 +6,13 @@ scoringQueue = require '../queues/scoring'
|
||||||
module.exports.setup = (app) ->
|
module.exports.setup = (app) ->
|
||||||
scoringQueue.setup()
|
scoringQueue.setup()
|
||||||
|
|
||||||
|
#app.post '/queue/scoring/pairwise', (req, res) ->
|
||||||
|
# handler = loadQueueHandler 'scoring'
|
||||||
|
# handler.addPairwiseTaskToQueue req, res
|
||||||
|
|
||||||
app.all '/queue/*', (req, res) ->
|
app.all '/queue/*', (req, res) ->
|
||||||
setResponseHeaderToJSONContentType res
|
setResponseHeaderToJSONContentType res
|
||||||
|
|
||||||
queueName = getQueueNameFromPath req.path
|
queueName = getQueueNameFromPath req.path
|
||||||
try
|
try
|
||||||
handler = loadQueueHandler queueName
|
handler = loadQueueHandler queueName
|
||||||
|
@ -23,6 +27,7 @@ module.exports.setup = (app) ->
|
||||||
catch error
|
catch error
|
||||||
log.error error
|
log.error error
|
||||||
sendQueueError req, res, error
|
sendQueueError req, res, error
|
||||||
|
|
||||||
|
|
||||||
setResponseHeaderToJSONContentType = (res) -> res.setHeader('Content-Type', 'application/json')
|
setResponseHeaderToJSONContentType = (res) -> res.setHeader('Content-Type', 'application/json')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue