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

@ -101,7 +101,7 @@ _.extend LevelSessionSchema.properties,
source: source:
type: 'string' type: 'string'
# TODO: specify this more # TODO: specify this more
code: code:
type: 'object' type: 'object'
@ -134,6 +134,45 @@ _.extend LevelSessionSchema.properties,
default: false default: false
index:true 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.extendBasicProperties LevelSessionSchema, 'level.session'
c.extendPermissionsProperties LevelSessionSchema, 'level.session' c.extendPermissionsProperties LevelSessionSchema, 'level.session'

View file

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