1
0
mirror of synced 2024-11-27 23:50:49 +01:00

Fix tenpo rank when read card

This commit is contained in:
asesidaa 2023-10-08 15:00:07 +08:00
parent 48956e758f
commit 66aaf027e2

View File

@ -25,15 +25,23 @@ public class GetTenpoScoreRankQueryHandler : IRequestHandlerWrapper<GetTenpoScor
private async Task<ServiceResult<string>> GetCardRank(long cardId, int tenpoId, CancellationToken cancellationToken)
{
var rank = await cardDbContext.GlobalScoreRanks.FirstOrDefaultAsync(scoreRank => scoreRank.CardId == cardId &&
scoreRank.LastPlayTenpoId == tenpoId,
cancellationToken: cancellationToken);
var ranks = await cardDbContext.GlobalScoreRanks.Where(rank => rank.LastPlayTenpoId == tenpoId)
.OrderByDescending(rank => rank.TotalScore)
.ToListAsync(cancellationToken: cancellationToken);
ranks = ranks.Select((rank, i) =>
{
rank.Rank = i + 1;
return rank;
}).ToList();
var rank = ranks.FirstOrDefault(rank => rank.CardId == cardId);
var container = new TenpoScoreRankContainer
{
Ranks = new List<ScoreRankDto>(),
Status = new RankStatus
{
TableName = "TenpoScoreRank",
TableName = "CardTenpoScoreRank",
StartDate = TimeHelper.DateToString(DateTime.Today),
EndDate = TimeHelper.DateToString(DateTime.Today),
Rows = 0,