Fix ranks
This commit is contained in:
parent
c2a6da0b83
commit
916482c1f7
@ -4,7 +4,7 @@ namespace SharedProject.Models;
|
|||||||
|
|
||||||
public class SongLeaderboard
|
public class SongLeaderboard
|
||||||
{
|
{
|
||||||
public uint Rank { get; set; }
|
public int Rank { get; set; }
|
||||||
|
|
||||||
public uint Baid { get; set; }
|
public uint Baid { get; set; }
|
||||||
|
|
||||||
|
@ -51,10 +51,15 @@ public class SongLeaderboardService : ISongLeaderboardService
|
|||||||
var playDatum = await context.SongPlayData
|
var playDatum = await context.SongPlayData
|
||||||
.Where(x => x.SongId == songId && x.Difficulty == difficulty && x.Baid == score.Baid)
|
.Where(x => x.SongId == songId && x.Difficulty == difficulty && x.Baid == score.Baid)
|
||||||
.FirstOrDefaultAsync();
|
.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
|
leaderboard.Add(new SongLeaderboard
|
||||||
{
|
{
|
||||||
Rank = (uint)leaderboard.Count + 1,
|
Rank = rank + 1,
|
||||||
Baid = score.Baid,
|
Baid = score.Baid,
|
||||||
UserName = user?.MyDonName,
|
UserName = user?.MyDonName,
|
||||||
BestScore = score.BestScore,
|
BestScore = score.BestScore,
|
||||||
@ -85,10 +90,14 @@ public class SongLeaderboardService : ISongLeaderboardService
|
|||||||
var user = await context.UserData
|
var user = await context.UserData
|
||||||
.Where(x => x.Baid == baid)
|
.Where(x => x.Baid == baid)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
var rank = await context.SongBestData
|
||||||
|
.Where(x => x.SongId == songId && x.Difficulty == difficulty && x.BestScore > currentUserScore.BestScore)
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
leaderboard.Add(new SongLeaderboard
|
leaderboard.Add(new SongLeaderboard
|
||||||
{
|
{
|
||||||
Rank = (uint)userRank + 1,
|
Rank = rank + 1,
|
||||||
Baid = currentUserScore.Baid,
|
Baid = currentUserScore.Baid,
|
||||||
UserName = user?.MyDonName,
|
UserName = user?.MyDonName,
|
||||||
BestScore = currentUserScore.BestScore,
|
BestScore = currentUserScore.BestScore,
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
@if (TotalPages > 1)
|
@if (TotalPages > 1)
|
||||||
{
|
{
|
||||||
<div class="d-flex flex-column align-center">
|
<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>
|
</div>
|
||||||
}
|
}
|
||||||
</PagerContent>
|
</PagerContent>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user