Fix ranks
This commit is contained in:
parent
c2a6da0b83
commit
916482c1f7
@ -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; }
|
||||
|
||||
|
@ -52,9 +52,14 @@ public class SongLeaderboardService : ISongLeaderboardService
|
||||
.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,
|
||||
@ -86,9 +91,13 @@ public class SongLeaderboardService : ISongLeaderboardService
|
||||
.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,
|
||||
|
@ -79,7 +79,7 @@
|
||||
@if (TotalPages > 1)
|
||||
{
|
||||
<div class="d-flex flex-column align-center">
|
||||
<MudPagination Class="pa-4" Count="@TotalPages" Selected="currentPage" SelectedChanged="(page) => OnPageChange(page)" BoundaryCount="1" MiddleCount="3" />
|
||||
<MudPagination Class="pa-4" Rectangular="true" DisableElevation="true" Count="@TotalPages" Selected="currentPage" SelectedChanged="(page) => OnPageChange(page)" BoundaryCount="1" MiddleCount="3" />
|
||||
</div>
|
||||
}
|
||||
</PagerContent>
|
||||
|
Loading…
x
Reference in New Issue
Block a user