diff --git a/ReplayBrowser/Controllers/ReplayController.cs b/ReplayBrowser/Controllers/ReplayController.cs index 20e797e..30505b8 100644 --- a/ReplayBrowser/Controllers/ReplayController.cs +++ b/ReplayBrowser/Controllers/ReplayController.cs @@ -32,7 +32,7 @@ public async Task GetPlayerData(Guid profileGuid) try { - return Ok(await _replayHelper.GetPlayerProfile(profileGuid, authState)); + return Ok(await _replayHelper.GetPlayerProfile(profileGuid, authState, TimeSpan.FromHours(2))); } catch (UnauthorizedAccessException e) { diff --git a/ReplayBrowser/Helpers/ReplayHelper.cs b/ReplayBrowser/Helpers/ReplayHelper.cs index 43fa1fc..dbed87a 100644 --- a/ReplayBrowser/Helpers/ReplayHelper.cs +++ b/ReplayBrowser/Helpers/ReplayHelper.cs @@ -60,7 +60,7 @@ public async Task> GetMostRecentReplays(AuthenticationState state) /// Fetches a player profile from the database. /// /// Thrown when the account is private and the requestor is not the account owner or an admin. - public async Task GetPlayerProfile(Guid playerGuid, AuthenticationState authenticationState, bool skipCache = false, bool skipPermsCheck = false) + public async Task GetPlayerProfile(Guid playerGuid, AuthenticationState authenticationState, TimeSpan cacheExpire, bool skipCache = false, bool skipPermsCheck = false) { var accountCaller = await _accountService.GetAccount(authenticationState); @@ -232,7 +232,7 @@ public async Task> GetMostRecentReplays(AuthenticationState state) }); } - _cache.Set(cacheKey, collectedPlayerData, TimeSpan.FromMinutes(120)); + _cache.Set(cacheKey, collectedPlayerData, cacheExpire); return collectedPlayerData; } diff --git a/ReplayBrowser/Pages/Profile.razor b/ReplayBrowser/Pages/Profile.razor index 6878c10..03615b7 100644 --- a/ReplayBrowser/Pages/Profile.razor +++ b/ReplayBrowser/Pages/Profile.razor @@ -162,7 +162,7 @@ else IsLoggedIn = true; } - _playerData = await ReplayHelper.GetPlayerProfile(guidParsed, authState); + _playerData = await ReplayHelper.GetPlayerProfile(guidParsed, authState, TimeSpan.FromHours(2)); _playerData.Characters = _playerData.Characters.OrderByDescending(x => x.RoundsPlayed).ToList(); _playerData.JobCount = _playerData.JobCount.OrderByDescending(x => x.RoundsPlayed).ToList(); } diff --git a/ReplayBrowser/Services/ProfilePregeneratorService.cs b/ReplayBrowser/Services/ProfilePregeneratorService.cs index 48b4143..bbf9905 100644 --- a/ReplayBrowser/Services/ProfilePregeneratorService.cs +++ b/ReplayBrowser/Services/ProfilePregeneratorService.cs @@ -121,7 +121,7 @@ private async void PregenerateProfiles() foreach (var guid in profilesToGenerate) { - await replayHelper.GetPlayerProfile(guid, new AuthenticationState(new ClaimsPrincipal()), true, true); + await replayHelper.GetPlayerProfile(guid, new AuthenticationState(new ClaimsPrincipal()), TimeSpan.FromDays(999), true, true); Log.Information("Pregenerated profile for {Guid}.", guid); _generatedProfiles.Add(guid); PregenerationProgress.Current++;