@page "/Settings/Tools/LongSessions" @inject PlaySessionService PlaySessionService @inject IMessageService MessageService @inject ILogger Logger @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]

These play sessions lasted longer than the threshold below. Extremely long sessions are usually the result of a session that was never properly ended, which can skew playtime statistics. Adjust the threshold and delete any sessions that look incorrect.

Threshold (hours)
@context.Game?.Title @context.User?.UserName @context.Duration?.ToString(@"d\.hh\:mm\:ss")
@code { ICollection PlaySessions; bool Loading = true; int ThresholdHours = 24; protected override async Task OnInitializedAsync() { await LoadData(); } async Task LoadData() { Loading = true; var threshold = TimeSpan.FromHours(ThresholdHours); var completedSessions = await PlaySessionService .Include(ps => ps.Game) .Include(ps => ps.User) .GetAsync(ps => ps.Start.HasValue && ps.End.HasValue); PlaySessions = completedSessions .Where(ps => ps.Duration.HasValue && ps.Duration.Value > threshold) .OrderByDescending(ps => ps.Duration) .ToList(); Loading = false; } async Task Delete(PlaySession playSession) { try { await PlaySessionService.DeleteAsync(playSession); await LoadData(); MessageService.Success("Session deleted!"); } catch (Exception ex) { MessageService.Error("Session could not be deleted."); Logger.LogError(ex, "Session could not be deleted."); } } async Task DeleteAll() { try { foreach (var playSession in PlaySessions.ToList()) await PlaySessionService.DeleteAsync(playSession); await LoadData(); MessageService.Success("Sessions deleted!"); } catch (Exception ex) { MessageService.Error("Sessions could not be deleted."); Logger.LogError(ex, "Sessions could not be deleted."); } } }