File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,11 +101,6 @@ public void ProcessBattle(SpringBattle battle)
101101 {
102102 Trace . TraceInformation ( battlesRegistered + " battles registered for WHR " + category + ", latest Battle: " + battle . SpringBattleID ) ;
103103 UpdateRatings ( ) ;
104- using ( var db = new ZkDataContext ( ) ) {
105- db . SpringBattlePlayers . Where ( p => p . SpringBattleID == battle . SpringBattleID && ! p . IsSpectator && playerOldRatings . ContainsKey ( p . AccountID ) ) . ForEach ( p => p . EloChange = playerRatings [ p . AccountID ] . RealElo - playerOldRatings [ p . AccountID ] . RealElo ) ;
106- db . SaveChanges ( ) ;
107- }
108- losers . Concat ( winners ) . ForEach ( x => playerOldRatings [ x ] = playerRatings [ x ] ) ;
109104 }
110105 }
111106 }
@@ -218,6 +213,16 @@ public void UpdateRatings()
218213 updateAction . Invoke ( ) ;
219214 Trace . TraceInformation ( "WHR " + category + " Ratings updated in " + DateTime . Now . Subtract ( start ) . TotalSeconds + " seconds, " + ( GC . GetTotalMemory ( false ) / ( 1 << 20 ) ) + "MiB total memory allocated" ) ;
220215 runningInitialization = false ;
216+
217+ if ( ! latestBattle . Equals ( lastUpdate ) )
218+ {
219+ using ( var db = new ZkDataContext ( ) )
220+ {
221+ db . SpringBattlePlayers . Where ( p => p . SpringBattleID == latestBattle . SpringBattleID && ! p . IsSpectator && playerOldRatings . ContainsKey ( p . AccountID ) ) . ForEach ( p => p . EloChange = playerRatings [ p . AccountID ] . RealElo - playerOldRatings [ p . AccountID ] . RealElo ) ;
222+ db . SpringBattlePlayers . Where ( p => p . SpringBattleID == latestBattle . SpringBattleID && ! p . IsSpectator ) . ForEach ( x => playerOldRatings [ x . AccountID ] = playerRatings [ x . AccountID ] ) ;
223+ db . SaveChanges ( ) ;
224+ }
225+ }
221226 }
222227 }
223228 catch ( Exception ex )
You can’t perform that action at this time.
0 commit comments