Skip to content

Commit

Permalink
don't load more than 20 items per request, 50 out of date per run
Browse files Browse the repository at this point in the history
  • Loading branch information
ervwalter committed Aug 6, 2024
1 parent b841c32 commit 8235118
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cache-updater/CacheUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ public async Task DownloadUpdatedGameDetailsAsync()
var cutoff = DateTimeOffset.UtcNow.AddHours(-6);
var random = new Random();
var outdated = _games.Where(g => g.Timestamp.AddHours(-1 * random.NextDouble()) < cutoff);
updateNeeded.UnionWith(outdated.Select(g => g.GameId).Take(100)); // don't update more than 100 outdated games per run
updateNeeded.UnionWith(outdated.Select(g => g.GameId).Take(50)); // don't update more than 100 outdated games per run

_log.LogInformation("Getting updated details for {0} new games and {1} out-of-date games", newCount, updateNeeded.Count - newCount);
_gamesById = _games.ToDictionary(g => g.GameId);
foreach (var ids in updateNeeded.Batch(25))
foreach (var ids in updateNeeded.Batch(20))
{
var games = await _client.GetGamesAsync(ids);
foreach (var game in games)
Expand Down

0 comments on commit 8235118

Please sign in to comment.