This commit is contained in:
Nick Winter 2014-02-17 11:54:30 -08:00
commit 1f7ba083d8
2 changed files with 45 additions and 6 deletions

View file

@ -100,8 +100,8 @@ _.extend LevelSessionSchema.properties,
type: 'object'
source:
type: 'string'
# TODO: specify this more
# TODO: specify this more
code:
type: 'object'
@ -134,6 +134,45 @@ _.extend LevelSessionSchema.properties,
default: false
index:true
submitDate:
type: c.date
title: 'Submitted'
submittedCode:
type: 'object'
matches:
type: 'array'
items:
type: 'object'
properties:
date: c.date
title: 'Time'
metrics:
type: 'object'
properties:
rank:
type: 'number'
opponents:
type: 'array'
items:
type: 'object'
properties:
id:
type: ['object', 'string']
codeSubmitDate: c.date
title: 'Submitted'
metrics:
type: 'object'
properties:
rank:
type: 'number'
c.extendBasicProperties LevelSessionSchema, 'level.session'
c.extendPermissionsProperties LevelSessionSchema, 'level.session'

View file

@ -174,7 +174,7 @@ module.exports.processTaskResult = (req, res) ->
if loggingError?
return errors.serverError res, "There as a problem logging the task computation: #{loggingError}"
updateScores clientResponseObject, (updatingScoresError, newScores) ->
updateSessions clientResponseObject, (updatingScoresError, newScores) ->
if updatingScoresError?
return errors.serverError res, "There was an error updating the scores.#{updatingScoresError}"
@ -204,10 +204,10 @@ logTaskComputation = (taskObject,taskLogObject, callback) ->
taskLogObject.save callback
updateScores = (taskObject,callback) ->
updateSessions = (taskObject,callback) ->
sessionIDs = _.pluck taskObject.sessions, 'sessionID'
async.map sessionIDs, retrieveOldScoreMetrics, (err, oldScores) ->
async.map sessionIDs, retrieveOldSessionData, (err, oldScores) ->
callback err, {"error": "There was an error retrieving the old scores"} if err?
oldScoreArray = _.toArray putRankingFromMetricsIntoScoreObject taskObject, oldScores
@ -245,7 +245,7 @@ putRankingFromMetricsIntoScoreObject = (taskObject,scoreObject) ->
scoreObject
retrieveOldScoreMetrics = (sessionID, callback) ->
retrieveOldSessionData = (sessionID, callback) ->
sessionQuery =
"_id":sessionID