File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 }
1515 grid .AddCol (" Commanders" , x => x .Accounts .Count ()).SetSort (x => x .Accounts .Count ());
1616 grid .AddCol (" Level" , x => (int ?)x .Accounts .Average (y => (double ?)y .Level )).SetSort (x => x .Accounts .Average (y => (double ?)y .Level ));
17- grid .AddCol (" Elo" , x => (int ?)x .Accounts .Average (y => (double ?)y .Elo )).SetSort (x => x .Accounts .Average (y => (double ?)y .Elo ));
17+ grid .AddCol (" Elo" , x => (int ?)x .Accounts .SelectMany (r => r .AccountRatings ).Where (r => r .RatingCategory == Ratings .RatingCategory .Casual ).Average (y => (double ?)y .RealElo ))
18+ .SetSort (x => x .Accounts .SelectMany (r => r .AccountRatings ).Where (r => r .RatingCategory == Ratings .RatingCategory .Casual ).Average (y => (double ?)y .RealElo ));
1819 if (GlobalConst .PlanetWarsMode != PlanetWarsModes .AllOffline )
1920 {
20- grid .AddCol (" PlanetWars Elo" , x => (int ?)x .Accounts .Average (y => (double ?)y .EloPw )).SetSort (x => x .Accounts .Average (y => (double ?)y .EloPw ));
21+ grid .AddCol (" PlanetWars Elo" , x => (int ?)x .Accounts .SelectMany (r => r .AccountRatings ).Where (r => r .RatingCategory == Ratings .RatingCategory .Planetwars ).Average (y => (double ?)y .RealElo ))
22+ .SetSort (x => x .Accounts .SelectMany (r => r .AccountRatings ).Where (r => r .RatingCategory == Ratings .RatingCategory .Planetwars ).Average (y => (double ?)y .RealElo ));
2123 }
2224 if (Global .Clan == null )
2325 {
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public static IRatingSystem GetRatingSystem(RatingCategory category)
6767 {
6868 if ( ! whr . ContainsKey ( category ) )
6969 {
70- Trace . TraceError ( "WHR: Unknown category " + category ) ;
70+ Trace . TraceWarning ( "WHR: Unknown category " + category + " " + new StackTrace ( ) ) ;
7171 return whr [ RatingCategory . MatchMaking ] ;
7272 }
7373 return whr [ category ] ;
Original file line number Diff line number Diff line change @@ -171,7 +171,6 @@ public void UpdateRatings()
171171 runIterations ( 50 ) ;
172172 UpdateRankings ( players . Values ) ;
173173 playerOldRatings = new Dictionary < int , PlayerRating > ( playerRatings ) ;
174- SaveToDB ( ) ;
175174 } ) ;
176175 }
177176 else if ( DateTime . UtcNow . Subtract ( lastUpdateTime ) . TotalHours >= GlobalConst . LadderUpdatePeriod )
@@ -181,7 +180,6 @@ public void UpdateRatings()
181180 Trace . TraceInformation ( "Updating all WHR " + category + " ratings" ) ;
182181 runIterations ( 1 ) ;
183182 UpdateRankings ( players . Values ) ;
184- SaveToDB ( ) ;
185183 } ) ;
186184 lastUpdateTime = DateTime . UtcNow ;
187185 }
@@ -194,7 +192,6 @@ public void UpdateRatings()
194192 players . ForEach ( p => p . runOneNewtonIteration ( ) ) ;
195193 players . ForEach ( p => p . updateUncertainty ( ) ) ;
196194 UpdateRankings ( players ) ;
197- SaveToDB ( players . Select ( x => x . id ) ) ;
198195 } ) ;
199196 }
200197 else
@@ -380,6 +377,14 @@ private void UpdateRankings(IEnumerable<Player> players)
380377 topPlayers = newTopPlayers ;
381378 Trace . TraceInformation ( "WHR " + category + " Ladders updated with " + topPlayers . Count + "/" + this . players . Count + " entries, max uncertainty selected: " + DynamicMaxUncertainty ) ;
382379
380+ var playerIds = players . Select ( x => x . id ) . ToList ( ) ;
381+ if ( playerIds . Count ( ) < 100 )
382+ {
383+ SaveToDB ( playerIds ) ;
384+ } else
385+ {
386+ SaveToDB ( ) ;
387+ }
383388
384389 //check for topX updates
385390 foreach ( var listener in topPlayersUpdateListeners )
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ private static void InitializeBattleRatings(ZkDataContext db)
3636 }
3737
3838 protected override void Seed ( ZkDataContext db ) {
39- InitializeBattleRatings ( db ) ; //remove this after execution
40- db . SaveChanges ( ) ;
39+ /* InitializeBattleRatings(db); //remove this after execution
40+ db.SaveChanges();*/
4141
4242 // This method will be called after migrating to the latest version.
4343 if ( GlobalConst . Mode == ModeType . Local )
You can’t perform that action at this time.
0 commit comments