From 96b838da03fd2fca4f99ebbdef1d637ed5dc5e54 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 20 Aug 2015 05:54:10 -0700 Subject: [PATCH] Fixed league-based simulation randomness. --- server/queues/scoring/createNewTask.coffee | 2 ++ server/queues/scoring/getTwoGames.coffee | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/queues/scoring/createNewTask.coffee b/server/queues/scoring/createNewTask.coffee index 2e63856b2..2a11d56c6 100644 --- a/server/queues/scoring/createNewTask.coffee +++ b/server/queues/scoring/createNewTask.coffee @@ -74,6 +74,8 @@ updateSessionToSubmit = (transpiledCode, user, sessionToUpdate, callback) -> league.stats.standardDeviation = 25 / 3 league.stats.numberOfWinsAndTies = 0 league.stats.numberOfLosses = 0 + league.stats.meanStrength ?= 25 + league.stats.totalScore ?= 10 newLeagues.push(league) unless _.isEqual newLeagues, sessionToUpdate.leagues sessionUpdateObject.leagues = sessionToUpdate.leagues = newLeagues diff --git a/server/queues/scoring/getTwoGames.coffee b/server/queues/scoring/getTwoGames.coffee index 375bcb6c0..36b7115cc 100644 --- a/server/queues/scoring/getTwoGames.coffee +++ b/server/queues/scoring/getTwoGames.coffee @@ -42,7 +42,7 @@ getRandomSessions = (user, callback) -> leagueIDs = (leagueID + '' for leagueID in leagueIDs) # Make sure to fetch them as strings. return sampleByLevel callback unless leagueIDs.length and Math.random() > 1 / leagueIDs.length leagueID = _.sample leagueIDs - findRandomSession {'leagues.leagueID': leagueID, favorRecent: true}, (err, session) -> + findRandomSession {'leagues.leagueID': leagueID}, (err, session) -> if err then return callback err unless session then return sampleByLevel callback otherTeam = scoringUtils.calculateOpposingTeam session.team