This commit is contained in:
Nick Winter 2014-03-10 08:45:39 -07:00
commit 6c7576a741
2 changed files with 18 additions and 1 deletions

View file

@ -146,6 +146,18 @@ _.extend LevelSessionSchema.properties,
numberOfLosses:
type: 'number'
default: 0
scoreHistory:
type: 'array'
title: 'Score History'
description: 'A list of objects representing the score history of a session'
items:
title: 'Score History Point'
description: 'An array with the format [unix timestamp, totalScore]'
type: 'array'
items:
type: 'number'
matches:
type: 'array'

View file

@ -443,10 +443,15 @@ updateScoreInSession = (scoreObject,callback) ->
if err? then return callback err, null
session = session.toObject()
newTotalScore = scoreObject.meanStrength - 1.8 * scoreObject.standardDeviation
scoreHistoryAddition = [Date.now(), newTotalScore]
updateObject =
meanStrength: scoreObject.meanStrength
standardDeviation: scoreObject.standardDeviation
totalScore: scoreObject.meanStrength - 1.8 * scoreObject.standardDeviation
totalScore: newTotalScore
$push:
scoreHistory: scoreHistoryAddition
LevelSession.update {"_id": scoreObject.id}, updateObject, callback
log.info "New total score for session #{scoreObject.id} is #{updateObject.totalScore}"