Skip to content

Commit 9a475cc

Browse files
committed
put ladders in db before sending out updates, fix clansindex
1 parent 5ac342f commit 9a475cc

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Zero-K.info/Views/Clans/ClansIndex.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
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
{

ZkData/Ef/WHR/WholeHistoryRating.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)