Added continuous simulation and fix for "no team"

This commit is contained in:
Michael Schmatz 2014-02-13 15:59:37 -08:00
parent 9bea226677
commit d33c39c21e
2 changed files with 6 additions and 2 deletions

View file

@ -106,11 +106,14 @@ module.exports = class HomeView extends View
onSimulateButtonClick: (e) => onSimulateButtonClick: (e) =>
@alreadyPostedResults = false @alreadyPostedResults = false
console.log "Simulating world!"
$.ajax $.ajax
url: "/queue/scoring" url: "/queue/scoring"
type: "GET" type: "GET"
error: (data) => error: (data) =>
console.log "There are no games to score. Error: #{data}" console.log "There are no games to score. Error: #{JSON.stringify data}"
console.log "Retrying in ten seconds..."
_.delay @onSimulateButtonClick, 10000
success: (data) => success: (data) =>
console.log data console.log data
levelName = data.sessions[0].levelID levelName = data.sessions[0].levelID
@ -161,6 +164,7 @@ module.exports = class HomeView extends View
console.log "TASK REGISTRATION ERROR:#{JSON.stringify error}" console.log "TASK REGISTRATION ERROR:#{JSON.stringify error}"
complete: (result) => complete: (result) =>
@alreadyPostedResults = true @alreadyPostedResults = true
@onSimulateButtonClick()
translateGoalStatesIntoTaskResults: (goalStates) => translateGoalStatesIntoTaskResults: (goalStates) =>

View file

@ -40,7 +40,7 @@ module.exports.createNewTask = (req, res) ->
LevelSession.find { "levelID": "project-dota", "submitted": true}, (err, submittedSessions) -> LevelSession.find { "levelID": "project-dota", "submitted": true}, (err, submittedSessions) ->
taskPairs = [] taskPairs = []
for session in submittedSessions for session in submittedSessions
if String(session._id) isnt req.body.session and session.team isnt sessionToScore.team if String(session._id) isnt req.body.session and session.team isnt sessionToScore.team and session.team in ["ogres","humans"]
taskPairs.push [req.body.session,String session._id] taskPairs.push [req.body.session,String session._id]
async.each taskPairs, sendTaskPairToQueue, (taskPairError) -> async.each taskPairs, sendTaskPairToQueue, (taskPairError) ->
return errors.serverError res, "There was an error sending the task pairs to the queue" if taskPairError? return errors.serverError res, "There was an error sending the task pairs to the queue" if taskPairError?