From 9b5387341439c957946536cce32f86b8096fd85f Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 17 Feb 2014 08:51:07 -0800 Subject: [PATCH 1/3] Updated session schema for session aggregation --- .../sessions/level_session_schema.coffee | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/server/levels/sessions/level_session_schema.coffee b/server/levels/sessions/level_session_schema.coffee index 4073d25ef..80892881f 100644 --- a/server/levels/sessions/level_session_schema.coffee +++ b/server/levels/sessions/level_session_schema.coffee @@ -100,11 +100,14 @@ _.extend LevelSessionSchema.properties, type: 'object' source: type: 'string' - - # TODO: specify this more + +# TODO: specify this more code: type: 'object' + submittedCode: + type: 'object' + teamSpells: type: 'object' additionalProperties: @@ -134,6 +137,38 @@ _.extend LevelSessionSchema.properties, default: false index:true + 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' From 302a13b6e72ebcfe7625f3ef88203f2e59ce489b Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 17 Feb 2014 09:23:49 -0800 Subject: [PATCH 2/3] Added submitDate to session schema --- server/levels/sessions/level_session_schema.coffee | 9 ++++++--- server/queues/scoring.coffee | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server/levels/sessions/level_session_schema.coffee b/server/levels/sessions/level_session_schema.coffee index 80892881f..7cb8ec229 100644 --- a/server/levels/sessions/level_session_schema.coffee +++ b/server/levels/sessions/level_session_schema.coffee @@ -105,9 +105,6 @@ _.extend LevelSessionSchema.properties, code: type: 'object' - submittedCode: - type: 'object' - teamSpells: type: 'object' additionalProperties: @@ -137,6 +134,12 @@ _.extend LevelSessionSchema.properties, default: false index:true + submitDate: + type: 'date' + + submittedCode: + type: 'object' + matches: type: 'array' items: diff --git a/server/queues/scoring.coffee b/server/queues/scoring.coffee index 5607d0ae8..48eb6f5e8 100644 --- a/server/queues/scoring.coffee +++ b/server/queues/scoring.coffee @@ -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 From 3b5d881c461d4b3be6f8830d6f61a8171dfa0563 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 17 Feb 2014 09:24:46 -0800 Subject: [PATCH 3/3] Changed schema date to proper format --- server/levels/sessions/level_session_schema.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/levels/sessions/level_session_schema.coffee b/server/levels/sessions/level_session_schema.coffee index 7cb8ec229..a21c02844 100644 --- a/server/levels/sessions/level_session_schema.coffee +++ b/server/levels/sessions/level_session_schema.coffee @@ -135,7 +135,8 @@ _.extend LevelSessionSchema.properties, index:true submitDate: - type: 'date' + type: c.date + title: 'Submitted' submittedCode: type: 'object'