mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-02 00:43:34 -04: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
server
|
@ -24,6 +24,25 @@ connectToScoringQueue = ->
|
|||
scoringTaskQueue = data
|
||||
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) ->
|
||||
requestSessionID = req.body.session
|
||||
validatePermissions req, requestSessionID, (error, permissionsAreValid) ->
|
||||
|
|
|
@ -6,6 +6,10 @@ scoringQueue = require '../queues/scoring'
|
|||
module.exports.setup = (app) ->
|
||||
scoringQueue.setup()
|
||||
|
||||
#app.post '/queue/scoring/pairwise', (req, res) ->
|
||||
# handler = loadQueueHandler 'scoring'
|
||||
# handler.addPairwiseTaskToQueue req, res
|
||||
|
||||
app.all '/queue/*', (req, res) ->
|
||||
setResponseHeaderToJSONContentType res
|
||||
|
||||
|
@ -24,6 +28,7 @@ module.exports.setup = (app) ->
|
|||
log.error error
|
||||
sendQueueError req, res, error
|
||||
|
||||
|
||||
setResponseHeaderToJSONContentType = (res) -> res.setHeader('Content-Type', 'application/json')
|
||||
|
||||
getQueueNameFromPath = (path) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue