This commit is contained in:
Scott Erickson 2014-03-22 09:40:34 -07:00
commit 3d308f03dc
2 changed files with 25 additions and 0 deletions

View file

@ -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) ->

View file

@ -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