From 13a74ba56027b73acadd9758db4830c905f05bfa Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 22 Mar 2014 09:17:14 -0700 Subject: [PATCH 1/2] Added resimulateAllSessions route --- server/routes/queue.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/routes/queue.coffee b/server/routes/queue.coffee index 10af6875f..18d8cc80b 100644 --- a/server/routes/queue.coffee +++ b/server/routes/queue.coffee @@ -14,6 +14,10 @@ module.exports.setup = (app) -> handler = loadQueueHandler 'scoring' handler.messagesInQueueCount req, res + app.post '/queue/scoring/resimulateAllSessions', (req, res) -> + handler = loadQueueHandler 'scoring' + handler.resimulateAllSessions req, res + app.all '/queue/*', (req, res) -> setResponseHeaderToJSONContentType res From d0232a36d9c3848eab5d7a32cfc1e528cc66a309 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 22 Mar 2014 09:19:21 -0700 Subject: [PATCH 2/2] Added resimulateSession method --- server/queues/scoring.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/queues/scoring.coffee b/server/queues/scoring.coffee index 982cf4124..fac34b59f 100644 --- a/server/queues/scoring.coffee +++ b/server/queues/scoring.coffee @@ -77,6 +77,27 @@ module.exports.resimulateAllSessions = (req, res) -> async.each result, resimulateSession.bind(@,originalLevelID,levelMajorVersion), (err) -> if err? then return errors.serverError res, err sendResponseObject req, res, {"message":"All task pairs were succesfully sent to the queue"} + +resimulateSession = (originalLevelID, levelMajorVersion, session, cb) => + sessionUpdateObject = + submitted: true + submitDate: new Date() + meanStrength: 25 + standardDeviation: 25/3 + totalScore: 10 + numberOfWinsAndTies: 0 + numberOfLosses: 0 + isRanking: true + LevelSession.update {_id: session._id}, sessionUpdateObject, (err, updatedSession) -> + if err? then return cb err, null + opposingTeam = calculateOpposingTeam(session.team) + fetchInitialSessionsToRankAgainst opposingTeam, originalLevelID, levelMajorVersion, (err, sessionsToRankAgainst) -> + if err? then return cb err, null + + taskPairs = generateTaskPairs(sessionsToRankAgainst, session) + sendEachTaskPairToTheQueue taskPairs, (taskPairError) -> + if taskPairError? then return cb taskPairError, null + cb null module.exports.createNewTask = (req, res) ->