diff --git a/SharedProject/Models/SongLeaderboard.cs b/SharedProject/Models/SongLeaderboard.cs index f61acfc..e490919 100644 --- a/SharedProject/Models/SongLeaderboard.cs +++ b/SharedProject/Models/SongLeaderboard.cs @@ -4,7 +4,7 @@ namespace SharedProject.Models; public class SongLeaderboard { - public uint Rank { get; set; } + public int Rank { get; set; } public uint Baid { get; set; } diff --git a/TaikoLocalServer/Services/SongLeaderboardService.cs b/TaikoLocalServer/Services/SongLeaderboardService.cs index 02db534..463eff2 100644 --- a/TaikoLocalServer/Services/SongLeaderboardService.cs +++ b/TaikoLocalServer/Services/SongLeaderboardService.cs @@ -51,10 +51,15 @@ public class SongLeaderboardService : ISongLeaderboardService var playDatum = await context.SongPlayData .Where(x => x.SongId == songId && x.Difficulty == difficulty && x.Baid == score.Baid) .FirstOrDefaultAsync(); + + // calculate Rank based on page/limit + var rank = await context.SongBestData + .Where(x => x.SongId == songId && x.Difficulty == difficulty && x.BestScore > score.BestScore) + .CountAsync(); leaderboard.Add(new SongLeaderboard { - Rank = (uint)leaderboard.Count + 1, + Rank = rank + 1, Baid = score.Baid, UserName = user?.MyDonName, BestScore = score.BestScore, @@ -85,10 +90,14 @@ public class SongLeaderboardService : ISongLeaderboardService var user = await context.UserData .Where(x => x.Baid == baid) .FirstOrDefaultAsync(); + + var rank = await context.SongBestData + .Where(x => x.SongId == songId && x.Difficulty == difficulty && x.BestScore > currentUserScore.BestScore) + .CountAsync(); leaderboard.Add(new SongLeaderboard { - Rank = (uint)userRank + 1, + Rank = rank + 1, Baid = currentUserScore.Baid, UserName = user?.MyDonName, BestScore = currentUserScore.BestScore, diff --git a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor index 47fbe92..8b13a21 100644 --- a/TaikoWebUI/Components/Song/SongLeaderboardCard.razor +++ b/TaikoWebUI/Components/Song/SongLeaderboardCard.razor @@ -79,7 +79,7 @@ @if (TotalPages > 1) {
- +
}