1
0
mirror of synced 2025-01-31 12:23:50 +01:00

Fix ranks

This commit is contained in:
shiibe 2024-06-04 23:01:42 -04:00
parent c2a6da0b83
commit 916482c1f7
3 changed files with 13 additions and 4 deletions

View File

@ -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; }

View File

@ -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,

View File

@ -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>